フィルターのクリア

How do i get the y value for a given x value?

1 回表示 (過去 30 日間)
nevin
nevin 2014 年 10 月 3 日
コメント済み: Stephen23 2014 年 10 月 6 日
I have plotted a frequency spectrum with the command "spect = fft(recording)" and "plot (abs(spect))" Is there a way that I can get matlab to give me the value of Y when the value of X is say 200Hz?

採用された回答

Star Strider
Star Strider 2014 年 10 月 3 日
You have to create a frequency vector as well to plot and interpret the fft correctly as a function of frequency, and for that you need the sampling frequency, (Fs) of ‘recording’. Then use interp1 to get the value at any specific frequency.
For example:
Fs = 1000; % Sampling Frequency
Ts = 1/Fs;
Tv = linspace(0,10*pi,505);
recording = sin(290*Tv).*cos(310*Tv)+rand(size(Tv));
spect = fft(recording);
specta = abs(spect);
Fn = Fs/2; % Nyquist Frequency
Fv = linspace(0, 1, length(spect)/2+1)*Fn;
Iv = 1:length(Fv); % Index vector
a200 = interp1(Fv, specta(Iv), 200); % Find Amplitude At 200 Hz
figure(1)
plot(Fv, specta(Iv), 200,a200,'pr') % Plot fft & Amplitude at 200 Hz
grid
  3 件のコメント
Star Strider
Star Strider 2014 年 10 月 6 日
My pleasure!
Stephen23
Stephen23 2014 年 10 月 6 日
Nice answer.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpectral Measurements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by