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

1 view (last 30 days)
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

Answers (1)

Alan Stevens
Alan Stevens on 18 Jan 2021
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 Comments
Alan Stevens
Alan Stevens on 19 Jan 2021
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 on 19 Jan 2021
sorry i mean 5s not 0.5s . but thank you for your clarification . thank you very much

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!