How make separate plots of one timeseries

I have a Simulink model which outputs a timeseries 'y_ss' to the workspace. The timeseries 'y_ss' contains three columns of data: each column corresponds to a state of my system. I want to make a plot for each column of data separately so that I can see the behavior of each state of my system. I've tried the following code to plot my first state (first data column) by itself:
clear all;
sim('HW2_P5model');
figure;
hold on;
plot(y_ss.Data:1),'b-');
xlabel('Time (sec)');
ylabel('Current (A)');
title('RLC Circuit Simulation');
legend('i_{L2}');
This doesn't give me anything at all. How can I plot each of the data columns individually in its own figure?
Thanks,
DMF

Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 15 Jun. 2015
Bearbeitet: Azzi Abdelmalek am 15 Jun. 2015

0 Stimmen

If the size of y_ss is nx3
sim('HW2_P5model')
time=y_ss.Time
y1=y_ss(:,1)
y2=y_ss(:,2)
y3=y_ss(:,3)
plot(t,y1,t,y2,t,y3)

2 Kommentare

The workspace says that y_ss is 1x1 timeseries. I tried implementing your solution to plot just the first data column:
clear all;
sim('HW2_P5model');
t=y_ss.Time;
y1=y_ss(:,1);
plot(t,y1);
and get the following error:
Error using timeseries/plot (line 27) The plot method can only be used for a single timeseries object
Error in HW2_P5 (line 6) plot(t,y1);
If I try to access y_ss(:,2), I also get an error saying that index exceeds matrix dimensions.
Any thoughts?
Azzi Abdelmalek
Azzi Abdelmalek am 15 Jun. 2015
Bearbeitet: Azzi Abdelmalek am 15 Jun. 2015
What is the size of y_ss.Data? and avoid using clear all

Melden Sie sich an, um zu kommentieren.

Kategorien

Tags

Gefragt:

am 15 Jun. 2015

Bearbeitet:

am 15 Jun. 2015

Community Treasure Hunt

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

Start Hunting!

Translated by