how to use repmat to plot?
3 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Cris LaPierre
2021 年 3 月 14 日
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 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!