matlab function fft, Error using fft Invalid data type. First argument must be double, single, int8, uint8, int16, uint16, int32, uint32, or logical.
28 次查看(过去 30 天)
显示 更早的评论
so i have to compute the fourier tranform of a signal but i got this error "Error using fft
Invalid data type. First argument must be double,
single, int8, uint8, int16, uint16, int32, uint32, or
logical."
here is my code
clc
syms t w
x=cos(2*pi*t/10);
f=fourier(x,w);
reversef=simplify(ifourier(f,t));
t = [0 5];
N1=64;
metroX=abs(fft(x,N1));
subplot(2,1,1)
plot(metroX,"Color",'red')
xlabel('METRO')
goniaX=angle(fft(x,N1));
subplot(2,1,2)
plot(goniaX,"Color",'green')
xlabel('FASI')
0 个评论
回答(1 个)
Paul
2022-3-30
At this line
metroX=abs(fft(x,N1));
the variable x is still a sym object. The input to fft() must be a sequence of actual numbers. Maybe it should be this:
N1=64;
t = linspace(0,5,N1); % define 64 time values
x = cos(2*pi*t/10); % define 64 x values
metroX=abs(fft(x,N1));
2 个评论
Cindy
2022-9-27
Hi, I got the same error. My case is that I have already on an excel the data, If I import the column to make the fft, I got the error.
Paul
2022-9-27
Are you sure the column imported was all numerical data?
Can't say anything more without seeing the Excel file (you can upload using the paperclip icon). Or load the data from the Excel file and type
>> whos varname
where varname is the actual variable that contains the data read in from Excel.
Hard to say much more without information on what you're passing to fft().
另请参阅
类别
在 Help Center 和 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!