Undefined function or method 'fft' for input arguments of type 'sym'.

2 ビュー (過去 30 日間)
Abdulaziz
Abdulaziz 2011 年 11 月 28 日
Hi Everyone: When I run this script:
syms t
x=-3:.1:3;
for i=1:length(x);
Pin=3*exp(-t^2);
z=x(i);
Eo(i)=int(Pin,t,-inf,z);
Ein(i)=int(Pin,t,-inf,inf);
E(i)=Eo (i)/Ein(i);
Go=1000;
G(i)=Go/(Go-(Go-1)*exp(-E(i)*0.1));
Pin=3*exp(-x(i)^2);
Pout(i)=Pin*G(i);
Poutf=fftshift(fft(Pout,100000));
f=(-100000/2:(100000/2-1)).*1/(0.01*100000);
end
plot(f,abs(Poutf),'-r*')
I face this error:
Undefined function or method 'fft' for input arguments of type 'sym'.
Could anyone help me please?

回答 (2 件)

Wayne King
Wayne King 2011 年 11 月 28 日
fft is not overloaded for symbolic inputs. fft() is only for numeric inputs. If you want the Fourier transform of a symbolic input, see fourier

Walter Roberson
Walter Roberson 2011 年 11 月 28 日
Use E(i) = double(Eo (i)/Ein(i));
Note: it is a waste of time to do the integrations ever iteration. Do the integration with a symbolic upper bound once before the loop, evaluate that with infinity as the upper bound once before the loop to get the constant Ein, and then in your loop subs() your x(i) in to the indefinite integral as the upper bound to get Eo(i).
The ratio will, by the way, come out as (1+erf(x(i))/2

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by