フィルターのクリア

How to plot a graph with negative and small value of X ..help..thx

19 ビュー (過去 30 日間)
elaine
elaine 2014 年 11 月 4 日
コメント済み: Star Strider 2014 年 11 月 4 日
This is my code...the result i want is a graph with negative values of X from -0.0025 to 0.0025...however, the result from the following is different with positve and large values of x..pls help me to change the code a bit..thxxx
tt = -0.00025:0.00001:0.00025
x1 = 20*cos(2*pi*(4000)*(tt -37.2/10));
tt = -0.00025:0.00001:0.00025
x2 = 24*cos(2*pi*(4000)*(tt +41.3/10));
x3= x1+x2
subplot(3,1,1),plot(x1)
title('X1')
xlabel('Time(sec)')
subplot(3,1,2),plot(x2)
title('X2')
xlabel('Time(sec)')
subplot(3,1,3),plot(x3)
title('X3')
xlabel('Time(sec)')

採用された回答

Star Strider
Star Strider 2014 年 11 月 4 日
You need to plot both the x and y vectors in your plot statements.
This works:
tt = -0.00025:0.00001:0.00025;
x1 = 20*cos(2*pi*(4000)*(tt -37.2/10));
tt = -0.00025:0.00001:0.00025;
x2 = 24*cos(2*pi*(4000)*(tt +41.3/10));
x3= x1+x2;
subplot(3,1,1)
plot(tt,x1)
title('X1')
xlabel('Time(sec)')
axis([min(tt) max(tt) ylim])
subplot(3,1,2)
plot(tt,x2)
title('X2')
xlabel('Time(sec)')
axis([min(tt) max(tt) ylim])
subplot(3,1,3)
plot(tt,x3)
title('X3')
xlabel('Time(sec)')
axis([min(tt) max(tt) ylim])
The axis function limits the axes to what you specify. If you want them to go from [-3,3] instead, simply remove the axis calls.

その他の回答 (1 件)

elaine
elaine 2014 年 11 月 4 日
Thank you sooo much...it's my first time using Matlab...^^
  1 件のコメント
Star Strider
Star Strider 2014 年 11 月 4 日
My pleasure!
MATLAB has a lot of online resources that will make it much easier for you to become proficient. If you have problems getting your code to run, we’re here to help!

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

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by