I have a script that imports a large dataset from a .csv file and converts it to Matlab objects of a custom class. The resulting output of the script is an array of these objects. The script takes roughly 8 hours to complete. Once I've imported and structured the data into the object array I'd like to save it so I only have to do it once and can utilize it in other scripts by simply loading the saved object array. I believe I'm able to do the save part properly – after the script is finished I just call the save('filename', 'variable') function from the Command Window to save my object array from the workspace. Where I'm running into problems is when I'm trying to load it in another script. For example, lets say I saved the object array as 'testObjArray.mat'. If I load it and try to call an attribute from it using the following code:
thisObjArray = load('testObjArray.mat')thisObjArray.name{1}
…I get a failure stating that I'm referencing a non-existent field 'name'. It seems like my problem is that when assigning thisObjArray with the load function I'm ending up with a struct rather than my object array. Is there a different way to load the file so that it remains an object array?
Thanks, Scott
Best Answer