Filter löschen
Filter löschen

how to use repmat to plot?

4 Ansichten (letzte 30 Tage)
Jinquan Li
Jinquan Li am 14 Mär. 2021
Beantwortet: Cris LaPierre am 14 Mär. 2021
i am plotting a graph of a unit step function: f(t) = u(t) - 2u(t - pi), for 0 <= t <= 2pi and i am trying to use repmat to make the orignal graph repeat 5 times. The graph looks good but the X-aixis domian is wrong. The time domian should be [0 10*pi] while the domain on the output graph is 5000. Here is my code and the graph:
t = linspace(0,2*pi,1000);
y = heaviside(t) - 2*heaviside(t-pi);
f = repmat(y,1,5);
plot(f)

Antworten (1)

Cris LaPierre
Cris LaPierre am 14 Mär. 2021
You have not specified an x input in your plot command. When you plot just y, the index number of the y value is used as the x value. You plot is showing that there are 5000 values in f.
Since you already now you want your intervale to be 0 to 10pi, you could do something like this.
plot(linspace(0,10*pi,length(f)),f)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by