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

2 visualizaciones (últimos 30 días)
Cheng
Cheng el 18 de En. de 2021
Comentada: Cheng el 19 de En. de 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

Respuestas (1)

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

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by