필터 지우기
필터 지우기

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