fft error in function?
显示 更早的评论
data_output is a 60000x2 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);
1 个评论
KSSV
2020-7-28
What for is this line?
f = 'data_output(:1)';
I guess it should be
f = data_output(:,1);
Isn't it? In your case what is
class(f)
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!