Need help with Boolean-type Plot vs Time
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Douglas Carter
el 5 de Mayo de 2015
Comentada: Star Strider
el 5 de Mayo de 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 comentarios
Respuesta aceptada
Star Strider
el 5 de Mayo de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Contour Plots en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!