NaN problem with graphing

3 ビュー (過去 30 日間)
imarquez
imarquez 2015 年 8 月 5 日
コメント済み: imarquez 2015 年 8 月 6 日
I am trying to graph Zf vs f for f:(10^6 to 10^10):
if true
format long
a = 1
b = 3*10.^-7
c = 5*10.^-8
f0 = 4*10.^9
sigma = 0.2
t0 = 0
tmax = 2*b
t = linspace(t0, tmax)
omega = 2*pi*f
omega0 = 2*pi*f0
yt = a*exp((-(t-b).^2)/((2*c).^2))
figure(1)
plot(t,yt)
zt = yt.*(1-((sigma/2)*(1-sin(omega0*t))))
figure(2)
plot(t,zt)
f = linspace(10.^6, 10.^10)
G = -2.*pi.*f.*(pi.*c.^2.*f + sqrt(-1).*b)
D = (((b-(sqrt(-1)).*2.*pi.*c.^2.*f-t0)/(sqrt(2).*c)))
E = (((b-(sqrt(-1)).*2.*pi.*c.^2.*f-tmax)/(sqrt(2).*c)))
Ff = sqrt(pi/2).*a.*c.*exp(G).*((-sqrt(-1).*(erfi(-sqrt(-1).*D)))-((-sqrt(-1).*(erfi(-sqrt(-1).*E)))))
Zf = ((1-(sigma/2)).*Ff) + (sqrt(-1).*sqrt(pi/2).*((a.*c.*sigma)/4).*exp(-((2.*pi.*f+omega0).*(c.^2.*(2.*pi.*f+omega0)+2.*sqrt(-1).*b)))).*(-exp(4.*pi.*c.^2.*f.*omega0+2.*sqrt(-1).*b.*omega0).*((-sqrt(-1).*erfi(((tmax-b+sqrt(-1).*c.^2).*(2.*pi.*f-omega0))/(sqrt(2).*c)))-(-sqrt(-1).*erfi(((t0-b+sqrt(-1).*c.^2).*(2.*pi.*f-omega0))/(sqrt(2).*c))))+(-sqrt(-1).*(erfi(((tmax-b+sqrt(-1)*c.^2).*(2.*pi.*f+omega0))/(sqrt(-1).*c))))-(-sqrt(-1).*erfi(((t0-b+sqrt(-1).*c.^2).*(2.*pi.*f+omega0))/(sqrt(-1).*c))))
figure(3)
plot(f,Zf)
% code
end
Why am I getting that both Ff and Zf are not a number for this evaluation? I've solved for Ff and it comes out to 0 (or at least really close to 0 and so the display was 0 when I solved for it). That wouldn't necessarily make Zf turn out 0 as well though since Ff is only multiplied against the first part in the equation Zf.
  3 件のコメント
Walter Roberson
Walter Roberson 2015 年 8 月 5 日
Your code uses f to define omega before you assign a value to f.
imarquez
imarquez 2015 年 8 月 6 日
I am using the symbolic toolbox. So i moved the definition of f up to right under the definition of t and removed the definition of omega since it wasn't used. I am still getting the NaN solution for all of Zf and all but columns 1 through 2 of Ff. Why would I get a value for the first two columns and nothing after that?
Also is there a way to evaluate the erfi() in imaginary terms?

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by