2

I have a compiled application which cannot properly save some user defined objects. When I try to load the mat file in the program it crashes with an Access Violation error. The mat file cannot be loaded in Matlab either (appears to be corrupt). However, the application runs smoothly before compilation. What are the possible causes for this?

classdef Audio < handle

properties
    ...
end

methods
    function self = Audio()
        ...
    end
end

end

a = Audio();
b = Audio();
c = Audio();
AudioVector = [a,b,c]

save(someFullPath, 'AudioVector')
  • I'd have to see the entire object to be sure, but have you explicitly implemented a `saveobj` and `loadobj` method? I find that usually those help by making things a little more explicit. Also it probably goes without saying but Audio.m should be on the path when you attempt to load this. – Suever Jan 16 '16 at 02:58
  • A possible workaround is to convert all objects to struct before saving them. – Daniel Jan 16 '16 at 09:35
  • @Suever I have made sure all the pathing is correct. However, I have not implemented a saveobj or loadobj method. My understanding of these methods is that they are used to clean up changed classes when saving or loading. Is that correct? I won't be able to make changes until Tuesday, but thenI can give the full code post. – user5797292 Jan 16 '16 at 13:03
  • @Daniel I will try this too. I won't be able to access the code until Tuesday, but I will give it a go. – user5797292 Jan 16 '16 at 13:04
  • @user5797292 the reason I mention saveobj and loadobj is that, yes, they essentially clean up the data prior to saving (replacing things that can't be properly serialized with things that can). We really have to see your property list to tell for sure what the issue is. You could be storing something that can't be serialized properly – Suever Jan 16 '16 at 13:44
  • All, thank you very much for the suggestions and the help. I figured out the problem: I loaded image data as one of the properties which apparently cannot be serialized in the same way as the rest of the data. I moved the loading somewhere else and it solved the problem. – user5797292 Jan 20 '16 at 16:40

0 Answers0