MATLAB: How to store an object (calculated in a function) so that we can use it later with a different script


So basically I have a script that calculates a lot of stuff, and in the process it creates an object that is not stored/saved in the command window's workspace. I have no way to use it unless I add code to the existing scripts.
I would like to feed that object to another script.
How can I store/save this object so that I can re-use it in the future?

Best Answer

  • Typically people use MAT files for this.
    a = rand(10);
    b = rand(12);
    save myMat a b
    clear all
    load myMat
    Hope that this helps
    Here is official example off their website