how to use repmat to plot?
8 views (last 30 days)
Show older comments
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)

0 Comments
Answers (1)
Cris LaPierre
on 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)
0 Comments
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!