필터 지우기
필터 지우기

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 CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by