Greetings. I have run up against the most infurating problem. I obviously broke something with a recent change, but I can't see how I possibly could have. Hopefully one of you detectives can help.
I have a custom class I'll just call classDataSet here for simplicity. classDataSet holds data in a property called dataSet as a table, and holds notes about that data in another property called dataSetNotes. This morning I made a change to how I was setting the dataSetNotes property. Originally I passed a 3 column table of notes to the set property method, did some validation to make sure it met expectations, and then set the property to that table.
The change I made started with writting another class (classLogBook) that deals with the administrative work of adding and working with notes. Now when I want to set the dataSetNotes property of classDataSet, I pass classLogBook to the set property method for dataSetNotes. This method just pulls a struct from classLogBook, converts it to table and saves it to the dataSetNotes property. Seems to me like barely any change at all. The end result is that the dataSetNotes property is still a three column table, regardless of how it is being set.
An all this works fine. Notes are visible in classDataSet after I set the property. There is no abnormal indication at all. UNTIL I trie to save classDataSet to a .mat file and load it again. After loading from file, the dataSetNotes property is empty. I dont' know if it isn't saving or it isn't loading. And I'm at a loss how to troubleshoot.
Here is the property set code
%% Property Set: dataSetNotes function obj = set.dataSetNotes(obj,logBookObject) % Accepts an object of classAvengerLogBook type and extracts the logbook.
if class(logBookObject) == "classLogBook" logBookStruct = logBookObject.logBookStruct; logBookTable = struct2table(logBookStruct); obj.dataSetNotes = logBookTable; else error("dataSetNotes property requires the passed argument to be an object of type classLogBook") end end
I can't imagine how it could be related, but here is the class constructor for the classLogBook object. The only interaction these two classes have is when classLogBook is passed to classDataSet to create a table that gets assigned to dataSetNotes (…which is the property that no longer save/loads).
%% Class Constructor function obj = classLogBook(logTitle) % Sets a default title if the user does not pass one.
obj.logBookStruct(1).time = UTC_Now; obj.logBookStruct(1).author = "Logbook Constructor"; if nargin == 1 obj.logBookStruct(1).entry = logTitle; else obj.logBookStruct(1).entry = "Title not Set"; end end
I appreciate any help you can give. Even if it is just an approach to troubleshooting what is going on.
Best Answer