matlab function fft, Error using fft Invalid data type. First argument must be double, single, int8, uint8, int16, uint16, int32, uint32, or logical.

22 次查看(过去 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')

回答(1 个)

Paul
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
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
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().

请先登录,再进行评论。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by