Need help with Boolean-type Plot vs Time
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Douglas Carter
am 5 Mai 2015
Kommentiert: Star Strider
am 5 Mai 2015
Right now I'm trying to use the stairs plot, but I can't get it to work the way I want. Not sure exactly how to do this. I have two matrices, one with on/off times every other column e.g [3 10 2 11 5 8 2 16 ...] and another is a dummy matrix I made to associate the on/off times with either "0" for off or "1" for on, i.e. [1 0 1 0 1 0 1 ...]
I would like to make a step plot where the on time is shown at the value "1" for the specified amount of time on the x-axis, then it switches to the off value "0" for the specified amount of off time, etc. So it is essentially a very basic signal.
Any ideas on how I might accomplish this? Thank you.
0 Kommentare
Akzeptierte Antwort
Star Strider
am 5 Mai 2015
You didn’t post your code so I can’t determine the reason it’s not working. I believe the problem is probably the way you defined your time vector. It has to be increasing in order to provide the type of plot I believe you want, so I used cumsum to create a workable time vector, ‘TS’ here.
This may do what you want (completely guessing though):
T = [3 10 2 11 5 8 2 16];
TS = cumsum(T);
S = [1 0 1 0 1 0 1 0];
figure(1)
stairs(TS, S)
axis([xlim 0 1.1])
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Contour Plots finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!