Logged signal data not being saved with the save command

4 views (last 30 days)
Hi,
I am running a simulink model and using logged signals to analyze the results of the sim. The problem I am having is that the logged signal data is not being saved (or loaded) when i try to save the logged signals with the save command.
Here is how I generate the data: I am storing the logged signals in a three dimensional matrix of simOut results.
% inside three for loops for r, c, pr. simOut = sim('Power_And_Cooling_Model'); simOutE(r,c,pr) = simOut;
After the loop runs, I want to save the simOutE data to a file, but I am running into two different problems:
1) Using the save (with the default file format version) never returns from the command prompt. It hangs matlab, or it is taking hours to save this data that is is not a practical solution. Looking online, I found a workaround to save in an older format, '-v7.3'.
2) When I save using this command,
save('test.mat', '-v7.3');
the file is created and the command seems to complete without error, but I noticed when I load the data (i.e. after quitting matlab), the following fields in the logged signal are not saved!
>> simOutE(1,1,1).get('logsout').MySignal ... TimeInfo: [] Time: [] Data: []
The data is there after the simulations run, but not when i try to save and subsequently load the data file. So, I think there is a bug/limitation in the save command? Is there anyway around this? It takes time to run the simulations and I want to run them once, save the data and do the analysis later.
I know matlab is using about 1.4GB of memory when i inspect the process with the windows task manager. I have over 3gb of memory on my laptop, and 100gb of free disk space. The v7.3 file is about a80MB.

Answers (1)

Fangjun Jiang
Fangjun Jiang on 16 Aug 2011
When you use simOut=sim(), simOut only contains the data for the returned time vector. If you want to save the logged data, you have to save it every time you finish the simulation, something like you did, logsoutAll(r,c,pr)=logsout.
At the end of all your simulation, you can then save logsoutAll to a .mat file.
  3 Comments
Fangjun Jiang
Fangjun Jiang on 16 Aug 2011
What version of MATLAB/Simulink are you using. I ran simout=sim('f14') in R2007b. "simout" only contains 1513x1 double array which is the simulation time "T". help sim
[T,X,Y] = SIM('model',TIMESPAN,OPTIONS,UT)
Fangjun Jiang
Fangjun Jiang on 16 Aug 2011
Now I tried it in R2010b. I saw sim() has been changed. I tried your approach in two iterations. It seems to work without any problem. Can you post your code?

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!