how to find the period for the 0.2s,0.8s,1s and 2s ?

2 ビュー (過去 30 日間)
Cheng
Cheng 2021 年 1 月 18 日
コメント済み: Cheng 2021 年 1 月 19 日
I succesfully run the program when the period is equal to 0.4 . but when i tried 0.2,0.8,1 and 2s . i got error. can anyone identify why is it wrong ?
When period = 0.4s

回答 (1 件)

Alan Stevens
Alan Stevens 2021 年 1 月 18 日
You need to change the size of the vectors etc appropriately. For example, for period = 0.2 you could have
T1 = 0.01;
t1 = 0:T1:0.199;
p1 = [ones(1,7) zeros(1,13)];
k1 = [0:10 -9:-1];
P1 = fft(p1)/20;
stem(k1,P1)
  7 件のコメント
Alan Stevens
Alan Stevens 2021 年 1 月 19 日
It still looks ok at 0.5s:
T1 = 0.1;
t1 = 0:T1:49;
p1 = [ones(1,17) zeros(1,33)];
k1 = [0:17 -32:-1];
P1 = fft(p1)/50;
stem(k1,P1)
I suggest that for 5s you limit the plot domain using the axis command:
T1 = 0.1;
t1 = 0:T1:499;
p1 = [ones(1,167) zeros(1,333)];
k1 = [0:167 -332:-1];
P1 = fft(p1)/500;
stem(k1,P1)
axis([-50 50 -0.1 0.35])
This produces
Cheng
Cheng 2021 年 1 月 19 日
sorry i mean 5s not 0.5s . but thank you for your clarification . thank you very much

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by