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

18 views (last 30 days)
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')

Answers (1)

Paul
Paul on 30 Mar 2022
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 Comments
Cindy
Cindy on 27 Sep 2022
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 on 27 Sep 2022
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().

Sign in to comment.

Categories

Find more on Fourier Analysis and Filtering in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!