how to use repmat to plot?

4 visualizaciones (últimos 30 días)
Jinquan Li
Jinquan Li el 14 de Mzo. de 2021
Respondida: Cris LaPierre el 14 de Mzo. de 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)

Respuestas (1)

Cris LaPierre
Cris LaPierre el 14 de Mzo. de 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)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by