フーリエ解析を使用した周波数解析について
Afficher commentaires plus anciens
フーリエ解析について質問です。
現在、0.5Hz 1Hz 2Hzのsin波に対して周波数解析を行っています。
結果、0.5Hz 1Hzにピークが出現し、2Hzにはピークが出現しません。 コードのどこか不足している部分があると考えましたが、原因がわからなく質問いたしました。
下記にコードを記載したのですが、修正必要な個所はありますでしょうか?
ご教示いただけると幸いです。 よろしくお願いいたします。
fs = 1000;% sample frequency(Hz)
model_timestep1 = (0:1/fs:10);
model_timestep2 = (10:1/fs:30);
model_timestep3 = (30:1/fs:40);
sinwave1 = sin(1*pi*0.5*model_timestep1);
sinwave2 = sin(1*pi*1*model_timestep2);
sinwave3 = sin(1*pi*2*model_timestep3);
S1 = horzcat(sinwave1(1:fs*10), sinwave2(1:fs*20), sinwave3(1:fs*10));
L = length(S1); % Window length
T = 1/fs; % sec sample
t = (0:L-1)*T;
Y = fft(S1);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f1 = fs*(0:(L/2))/L;
subplot(2,1,1);
plot(S1);
axis([0 inf -inf inf]);
subplot(2,1,2);
plot(f1,P1)
ylabel('FFT');
axis([0 5 0 inf]);
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur 変換 dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!