フィルターのクリア

FFT error 'not supported to carry out script fft as a function'

2 ビュー (過去 30 日間)
柊介 小山内
柊介 小山内 2022 年 12 月 8 日
コメント済み: 柊介 小山内 2022 年 12 月 13 日
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

採用された回答

Paul
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))
X(w) = 
Convert to Thz
syms fThz
X(fThz) = X(2*sym(pi)*(fThz*1e12))
X(fThz) = 
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 件のコメント
柊介 小山内
柊介 小山内 2022 年 12 月 13 日
編集済み: 柊介 小山内 2022 年 12 月 13 日
I don't know whether this is useful for you, my program I wrote part of it published here.
syms t f fTHz w
T=1/(5.0*10^10);
roll = 0.3;%roll-off β
a=(1-roll)/(2*T)
A = pi*t/T;
%x(t)= sin(A)/A*cos(roll*A)/(1-(2*roll*t/T)^2);
nch = 11;%number of mountain part
m =T/2*(1+cos(pi*T/roll))*(f-a);
A=zeros(size(nch));
for n = -round(nch/2):round(nch/2)
f= -a+50*10^9*n:1.0*10^9:a+50*10^9*n 
x(f)=piecewise(-a+50*10^9*n<=f<=a+50*10^9*n,T,a+50*10^9*n<=f<=(1+roll)/(2*T)+50*10^9*n,m);
A(n)=x(f);
end
柊介 小山内
柊介 小山内 2022 年 12 月 13 日
sorry I can solve my problem. thank you for help me!

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
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 件のコメント
柊介 小山内
柊介 小山内 2022 年 12 月 9 日
sorry I forgot to add sample. If graph plot carried out correctly, X(f) is ploted as below.(green line)
You don't worry about amplitude. Shape of graph is most important. This graph shows how much larger is the GNLI(blue line) than X(f).
Walter Roberson
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))
y(f) = 
char(x)
ans = '-(sin(2000000000*t*pi)*cos(600000000*t*pi))/(2000000000*t*pi*(1440000000000000000*t^2 - 1))'
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 ExchangeCalculus についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by