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

29 views (last 30 days)
Andreas Makrides
Andreas Makrides on 30 Mar 2022
Edited: Walter Roberson on 30 Mar 2022
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));

Tags

Community Treasure Hunt

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

Start Hunting!