Need help with Boolean-type Plot vs Time
9 views (last 30 days)
Show older comments
Douglas Carter
on 5 May 2015
Commented: Star Strider
on 5 May 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 Comments
Accepted Answer
Star Strider
on 5 May 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])
More Answers (0)
See Also
Categories
Find more on Contour Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!