How to keep same time range when sending data form Simulink to Matlab?

hi, I am Simulating a model in simulink and want to plot a graph of the output in MatLAB, but when i send it to MatLAB the time range changes, for example, when its in Simulink, its 300 seconds but when sent to MatLAB its 1200 seconds, basically I want the same response from the scope only in MatLAB.
Thanks
Johnny

 採用された回答

Fangjun Jiang
Fangjun Jiang 2011 年 5 月 2 日

0 投票

I suspect you are viewing partial of your curve in Simulink scope. See this post: http://www.mathworks.com/matlabcentral/answers/5591-scope-time-not-shown-to-full-simlation
You may have ploted your curve in Matlab without time so your x-axle is just number of data samples. By default, the simulation time is sent to the workspace as "tout", so try, plot(tout, YourVariable). You can change this by click menu:
Simulation-> Configuration parameters ... -> Data Import/Export

4 件のコメント

Johnny
Johnny 2011 年 5 月 2 日
I tried that, and it says that vectors must be same length, as for the data import/export nothing has changed. would it have anything to do with the solver in the configuration parameters? I have been doing this months now and can never seem to get my graphs right.
thanks
johnny.
Kaustubha Govind
Kaustubha Govind 2011 年 5 月 2 日
I suspect that your variable is the output from a block that runs at a lower sample-rate than the base-rate of the model (the time-steps are logged in tout). In order to log the time-steps corresponding to your signal, you can save the signal as a "Structure with Time" format. You can either use the Data Import/Export pane as Fangjun suggested, or use the "To Workspace" block to log your signal to the MATLAB workspace as a "Structure with Time" Once you have done this, you should be able to use something like:
plot(YourVariable.time, YourVariable.signals.values)
Johnny
Johnny 2011 年 5 月 2 日
thanks very much guys, that was great help. its for my final year project so it needs to be perfect.
johnny
papan dey
papan dey 2013 年 2 月 6 日
i have generated simulink figure and can convert it in matlab using plot(signal) . now if i want to take the graph between a time limit such as 0.2s t0 0.5s, which command should i write?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeSimulink Environment Customization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by