Effacer les filtres
Effacer les filtres

how to use repmat to plot?

4 vues (au cours des 30 derniers jours)
Jinquan Li
Jinquan Li le 14 Mar 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)

Réponses (1)

Cris LaPierre
Cris LaPierre le 14 Mar 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)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by