From: Andrew Gartland on
Hi,
I have made a class that inherits from handle that I want to be able to save to a mat file. It has other custom classes in it so i need to overide the saveobj method. I've done this and about half the time on one computer and all the time on a different computer the class saves and loads flawlessly using save(filename, object); from the prompt.

Sometimes the save operation fails. When it does it reports:
??? Error using ==> save
Error closing file F:/rf/sb/091006B.mat.

I've done some digging around to try and find the problem. I can catch the error with a try...catch. If I call the obj.saveobj() method directly instead of calling save(fn, obj) I get back a struct that looks fine and can be saved using save('temp.mat',tempStruct);

One weird thing I've noticed is that my saveobj() method seems to get called twice when i call save() on my object. It only fails on the second call to the saveobj() method. Why is it called twice? Is this related to my problem?

Since I can only catch an error when using save() but not saveobj() method, it does not appear that the error is in my code but rather in save(). Does anyone agree/disagree with this? Has anyone experienced similar problems. Thanks for the help. Please email me. Thanks!

Andrew
 | 
Pages: 1
Prev: Multiple Tabs with dlmwrite
Next: fopen funniness