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 CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by