Periodic functions show up as a straight line

3 ビュー (過去 30 日間)
Hieu Nguyen
Hieu Nguyen 2017 年 11 月 2 日
コメント済み: KSSV 2017 年 11 月 2 日
Hello everyone!
When I plot the multiplots in one figure, only x1 shows up as a true graph of a periodic function, the rest shows up as straight lines. It is true for x0 as a straight line as it is a constant function. What goes wrong in my code? Thank you in advance.
t = 0:0.000001:2;
x0 = 0.0507*cos(0*pi*t);
figure
plot(t,x0)
set(gca,'fontsize',13)
title('Plot 1:Spanning over one period')
hold on
x1 = 0.645*cos(pi*t - 3.14/2);
plot(t,x1)
x3 = 0.00057*cos(3*pi*t - 3.116);
plot(t,x3)
x5 = 0.0000684*cos(5*pi*t - 3.126);
plot(t,x5)
legend('x0','x1','x3','x5')
xlabel('time t (second)')
ylabel('x(t) in meter')
hold off
  2 件のコメント
KSSV
KSSV 2017 年 11 月 2 日
All expect x0 periodic functions.....but the amplitude of them is low....compared to the amplitude of x1....that's why it shows up like straight line.
Hieu Nguyen
Hieu Nguyen 2017 年 11 月 2 日
Can I fix that? It seems odd, but what you explained to me makes sense.

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 11 月 2 日
You have
x0 = 0.0507*cos(0*pi*t);
which is going to be cos(0) * 0.0507 = 0.0507 for all t -- a straight line.
You have
x1 = 0.645*cos(pi*t - 3.14/2);
which successfully plots as expected.
You have
x3 = 0.00057*cos(3*pi*t - 3.116);
which has a maximum amplitude of 0.00057 which is too small an amplitude change to show up unless you zoom in.
You have
x5 = 0.0000684*cos(5*pi*t - 3.126);
which is about an 8 time smaller amplitude yet, and would need even more zooming in to so.
  2 件のコメント
Hieu Nguyen
Hieu Nguyen 2017 年 11 月 2 日
how can I zoom in? is there a command in matlab allowing me to do that? Thanks!
KSSV
KSSV 2017 年 11 月 2 日
There would be magnifying glass symbol on the plot ...click on it.....

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGraphics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by