MATLAB: Fft error in function

fft

data_output is a 60000×2 matrix.
Concerning line the line that is highlighted with arrows, "fhat = fft(f,n);", I keep recieving "Error using fft
Invalid data type. First argument must be double, single, int8, uint8, int16, uint16, int32,uint32, or logical.".
What can I do to make the code function? Are either t or f that is the problem?
dt = .001;
t = 0:dt:1;
f = 'data_output(:1)';
figure;
plot(t,ffilt); ",
dt = .001;
%dt = 0.00001666667;
t = 0:dt:1;
f = 'data_output(:1)';
figure;
plot(data_output)
xlabel('time(s)');
ylabel('Amplitude');
grid on
%% Compute the Fast Fourier Transform FFT
n = length(t);
----------------------------- >>>fhat = fft(f,n); <<< ------------------------
PSD = fhat.*conj(fhat)/n;
freq = 1/(dt*n)*(0:n);
L = 1:floor(n/2);
figure;
dim = 2;
plot(f,fhat,2); % FFT plot
xlim([0 1]);
xlabel('Frequency(Hz)');
ylabel('FFT Magnitude');
grid on
%% USe the PSD to filter out noise
indices PSD>35000;
PSDclean = PSD.*indices;
fhat = indices.*fhat;
ffilt = ifft(fhat);
figure;
plot(t,ffilt);

Best Answer

f = 'data_output(:1)';
That is a character vector. You cannot fft() a character vector.
If you need to apply fft to the ASCII codes that are used for the letters 'd' 'a' 't' and so on, then fft(double(f), n) . I would, however, suggest that it is very unlikely that is what you want, and that instead your line should be something closer to
f = data_output(:,1);
where data_output would be replaced by the name of the variable whose first column you want to extract.
plot(t,ffilt); ",
ffilt is not defined at that point.
You have a stray double-quote on that line.
plot(f,fhat,2); % FFT plot
When you use more than one numeric input to plot(), then you must have an even number of numeric inputs.
dim = 2;
That line hints that the 2 in your plot might refer to the second dimension, but your fhat looks like it will be a vector so it does not appear that giving the dimension would be useful.
If you are expecting that f or fhat are 2D arrays, then some of your other lines will have problems.
indices PSD>35000;
There is no MATLAB function named indices to invoke on the character vector 'PSD>35000' . I would suspect
indices = PSD>35000;