Record simulation data to use it in an other simulation
1 回表示 (過去 30 日間)
古いコメントを表示
Hi,
I need to create a block in simulink that works like a memory: it must record input values and it must allow me to get a specific value in an other simulation.
Example: If i've a simulink model with a signal, the block i need must memorize signal values for all instants t. In an other simulation (an other model with possibly an other simulation time) i can get the signal value for my specific t (example "give me the signal value at t=6s") from first simulation recording.
I tried to use "to File" and "from File" blocks for this purpose and to connect it to an embedded function to get some specific value, but testing this blocks there is following problem:
Sine Wave---->To File (in a simulation with simulation time of 5s)
From File---->Scope (in an other simulation with simulation time of 10s)
In the Scope the sine wave is that of 1st simulation but from t=5s to end it turns and becomes a ramp!!
0 件のコメント
回答 (1 件)
Paulo Silva
2011 年 3 月 27 日
I tested what you said, the scope draws the signal until it ends and continues to draw what appears to be a ramp (it keeps the variation of the wave in the end values), it's weird behavior but the file data is correct, I tested it with the code:
a=load('untitled.mat'); %load the file (sine wave from 0 to 5 seconds)
plot(a.ans(1,:),a.ans(2,:)) %plot the wave
axis([0 10 -1 1]) %define the axis so we can check if there's a ramp or not
There's no ramp in the plot, just the sine wave from 0 to 5 seconds,conclusion: it's just the scope acting weird.
Instead of saving the data to a file you should save it to the workspace.
After searching a litle in the documentation I found the reason why the ramp appears, see the From File documentation:
*Missing and Duplicate Time Stamps
If an output value is needed at a time that falls between two values in the MAT-file, the value is linearly interpolated between the appropriate values. If the required time is less than the first time value or greater than the last time value in the MAT-file, Simulink software extrapolates, using the first two or last two data points to compute a value.*
8 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!