how to plot data saved as file using "TO FILE" block in Simulink

2 views (last 30 days)
Please help me for this. how to plot data saved as file using "TO FILE" block in Simulink. Thank you in advance

Answers (1)

Paulo Silva
Paulo Silva on 7 Apr 2011
That depends on the data, the To File block writes data as a matrix of two or more rows. The block writes one column to the MAT-file for each time step. The first element of the column contains the simulation time. The remainder of the column contains scalar or vector data for the time shown at the top of the column.
For example if you save to one mysimdata.mat file and use the variable ans for the ouput:
load('mysimdata') %load the saved data
s=2; %second row got the signal
plot(ans(1,:),ans(s,:)) %first row is the time
if you got more signals in there
s=3; %third row got the data you want to plot
plot(ans(1,:),ans(s,:))
more signals just add one to s and plot it
plot(ans(1,:),ans(s,:))

Products

Community Treasure Hunt

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

Start Hunting!