FFt of X (DATA:901) and y (DATA:901)

2 次查看(过去 30 天)
hallo people pls I need your help. I have a plot of reflectance against wavelength. I need to generate the FFT of this data. I though I need to change my wavelength to frequency unit. but the code belows tells me that error'matrix must have the same length. what can do to solve this problem and how I put my y datain the code? or can someone give a generall code I just put my y and X DATA.
Fs = 150; % Sampling frequency t = 0:1/Fs:1; % Time vector of 1 second f = y; % Create a sine wave of f Hz. x cos(2*pi*t*f); nfft = 901; % Length of FFT X = fft(x,nfft); X = X(1:nfft/2); % Take the magnitude of fft of x mx = abs(X); % Frequency vector f = (0:nfft/2-1)*Fs/nfft; Power Spectrum of a Cosine Wave % Generate the plot, title and labels. figure(1); plot(t,x); title('Sine Wave Signal'); xlabel('Time (s)'); ylabel('Amplitude'); figure(2); plot(f,mx); title('Power Spectrum of a Sine Wave'); xlabel('Frequency (Hz)'); ylabel('Power');
  1 个评论
Jordy Jose
Jordy Jose 2018-2-1
Hi Jean,
It will be great if you could put the code in a code block so that it is more readable. That will make it easier for others to comprehend and respond faster.

请先登录,再进行评论。

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by