MATLAB: FFT Plot different Vector not same length

fftplotvectors

I am not getting any plots from my FFT of a 2X60000 database of the i and q channels of a dobbler radar measuring movment. I recieve "Error using plot Vectors must be the same length. Error in Julytwentyseventh (line 21) plot(t, f), hold on" for the first plot line. I've changed my value of t from t = 0:dt:1, and to t = 0:dt:60000. Same results.
dt = .001;
t = 0:dt:600;
f = data_output;
%%Compute the Fast Fourier Transform FFT
n = length(t);
fhat = fft(f,n); % Compute the fast Fourier transform
PSD = fhat.*conj(fhat)/n; % Power spectrum (power per freq)
freq = 1/(dt*n)*(0:n); % Create x-axis of frequencies in Hz
L = 1:floor(n/2); % Only plot the first half of freqs
%%Use the PSD to filter out noise
indices = PSD>100; % Find all freqs with large power
PSDclean = PSD.*indices; % Zero out all others
fhat = indices.*fhat; % Zero out small Fourier coeffs. in Y
ffilt = ifft(fhat); % Inverse FFT for filtered time signal
%%PLOTS
plot(t, f), hold on
plot (f, fft), hold on
plot (t,ffilt);

Best Answer

Try this:
plot(t, f(1:n)), hold on
plot (freq(L), fhat(L)), hold on
plot (t,ffilt(1:n));
Note that with no knowldege of ‘f’ or ‘data_output’, writing exact code is not possible.
There may still be problems if there is a discrepancy in the sizes of ‘t’ and ‘f’.
.