How do i get the y value for a given x value?
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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?
0 commentaires
Réponse acceptée
Star Strider
le 3 Oct 2014
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Spectral Measurements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!