plotting step function with variable step length
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to do a plot of y as a function of time. Where the values of y are either zero or one and they alternate. The time that y is either zero or one is given by t(n) where I solved for t(n) (a vector of different times). Basically I want to have y(t=0 -> t=t(1)) = 0, then y(t=t(1) -> t = t(2)) = 1, then y(t = t(2) -> t(3)) = 0, and so on. I have already solved for a distribution of the t's. I just don't know how to plot this.
1 Kommentar
Henrik
am 15 Dez. 2014
Your notation is difficult to understand, so I don't know exactly what you're asking.
From what I understood, you could make a vector of the t-values, another vector with the y-values, and plot them using
plot(t,y)
example:
t=[1 2 4 6 7 9];
y=[1 1 -1 0 -1 1];
plot(t,y)
Antworten (1)
Guillaume
am 15 Dez. 2014
One possible way:
t=[2 7 10 15 20]; %for example
x = [0 reshape(repmat(t(1:end-1), 2, 1), 1, []) t(end)];
y = repmat([1 1 0 0], 1, ceil(numel(x)/4));
y = y(1:numel(x));
plot (x, y)
Siehe auch
Kategorien
Mehr zu Descriptive Statistics and Visualization finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!