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

2 Ansichten (letzte 30 Tage)
Cheng
Cheng am 18 Jan. 2021
Kommentiert: Cheng am 19 Jan. 2021
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

Antworten (1)

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

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by