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

1 次查看(过去 30 天)
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

更多回答(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