FFT error 'not supported to carry out script fft as a function'
조회 수: 2 (최근 30일)
이전 댓글 표시
I want to plot a graph as below. so I wrote a program using fft. but error message 'not supported to carry out script fft as a function' displayed. What should I do?
syms t f
T=5.0*10^(-10);
roll = 0.3;%roll-off β
A = pi*t/T;
x(t)= sin(A)/A*cos(roll*A)/(1-(2*roll*t/T)^2);
ht=matlabFunction(x(t));
y=fft(x(t));
X = f;
Y = y;
plot(X,Y);
formula of x(t),X(f) and graph I want to plot(green line) are shown as follows
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1223717/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1223722/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1223727/image.jpeg)
댓글 수: 0
채택된 답변
Paul
2022년 12월 9일
Hi 柊介 小山内,
fourier can return a closed form expression with a little help.
syms t w f real
T = sym(5.0)*10^(-10);
roll = sym(0.3);%roll-off β
A = sym(pi)*t/T;
x(t) = sin(A)/A*cos(roll*A)/(1-(2*roll*t/T)^2);
rewrite x(t) in terms of expoentials before taking the Fourier transform.
X(w) = simplify(fourier(rewrite(x(t),'exp'),t,w))
Convert to Thz
syms fThz
X(fThz) = X(2*sym(pi)*(fThz*1e12))
The plot doesn't look like yours, actually it looks like one cycle of yours. However, I also don't see how the the plots you've posted for X(f) match the equation you've posted for X(f)
xfunc = matlabFunction(X(fThz)/T);
figure
plot(-0.01:.00001:0.01,abs(xfunc(-0.01:.00001:0.01)))
댓글 수: 9
추가 답변 (1개)
Walter Roberson
2022년 12월 8일
you named your file fft.m which makes it impossible to call the Mathworks fft function. You need to rename your fft.m
댓글 수: 5
Walter Roberson
2022년 12월 9일
편집: Walter Roberson
2022년 12월 9일
syms t f
T = sym(5.0)*10^(-10);
roll = sym(0.3);%roll-off β
A = sym(pi)*t/T;
x(t)= sin(A)/A*cos(roll*A)/(1-(2*roll*t/T)^2);
y(f)=fourier(x(t))
char(x)
Notice that the result has unevaluated calls to fourier(). That means that fourier() was unable to compute the fourier transform of that function.
I checked on Wolfram Alpha, which was able to come up with a transformation... but MATLAB is not able to do so.
참고 항목
카테고리
Help Center 및 File Exchange에서 Calculus에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!