Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

NaN value and two similar code:one correct & one with error

1 visualizzazione (ultimi 30 giorni)
Moein
Moein il 8 Ott 2015
Chiuso: MATLAB Answer Bot il 20 Ago 2021
hi friends i have two similar codes:
1)
a=6.62*(10^(-8));
h=[5.9e-06,0.8e-06,1.7e-06,1.7e-06];
k=6.62*(10^(-8));
L=[0.08,0.02];
s(1,1)=-h(1,1)/k;
s(1,2)=h(1,2)/k;
s(2,1)=-h(1,3)/k;
s(2,2)=h(1,4)/k;
j=[22.65037995,54.73643261,89.96745110,126.6631845,164.2134375,202.2829328,240.6796079,279.2910447,318.0491506,356.9110558,395.8487379,434.8432425,473.8813525,512.9536011,552.0530460,591.1744890,630.3139660,669.4684039,708.6353855,747.8129847;48.60546148,171.9080619,322.1146808,476.6215653,632.3771305,788.6531669,945.1940049,1101.887531,1258.676997,1415.530639,1572.429308,1729.360778,1886.316878,2043.291942,2200.281917,2357.283826,2514.295437,2671.315041,2828.341307,2985.373186];
for m=1:2
for n=1:20
f(m,1,n)=(((j(m,n)^2)+(s(m,1)*s(m,2)))^2)+(j(m,n)^2)*((s(m,2)-s(m,1))^2);
f(m,2,n)=L(1,m)*((j(m,n)^2)+(s(m,1)^2))*f(m,1,n);
f(m,3,n)=(s(m,2)-s(m,1))*((j(m,n)^4)-((j(m,n)^2)*s(m,1)*(s(m,2)-s(m,1)))-((s(m,1)^3)*s(m,2)));
end
end
for m=1:2
for n=1:20
A(m,n)=(2*f(m,1,n))/(f(m,2,n)+f(m,3,n));
end
end
for m=1:2
for n=1:20
B(m,n)=sin(j(m,n)*L(1,m))+(s(m,1)/j(m,n))*(cos(j(m,n)*L(1,m))-1);
end
end
for m=1:2
for n=1:20
C(m,n)=A(m,n)*B(m,n);
end
end
syms x y t
X=0
Y=0
for n=1:20
X=C(1,n)*(exp((-a)*(j(1,n)^2)*4586.735162*t))*(j(1,n)*cos(j(1,n)*0.08*x)-s(1,1)*sin(j(1,n)*0.08*x))+X;
Y=C(2,n)*(exp((-a)*(j(2,n)^2)*4586.735162*t))*(j(2,n)*cos(j(2,n)*0.08*y)-s(2,1)*sin(j(2,n)*0.08*y))+Y;
end
teta=(X*Y);
T=((7)*teta)+0.196;
V=subs(teta,[x y],[0.5 0.125]);
ezplot(V)
2)
h=[0.643,0.32,0.6876];
L=5.027;
j=[0,0.9334540347,3.420676259,6.432521384,9.525757414,12.64249311,15.76900707,18.90049224,22.03484279,25.17099331,28.30834773,31.44654673,34.58536093,37.72463707,40.86426886,44.00418027,47.14431549,50.28463265,53.42509969,56.56569167;0.3546720053,0.8850081993,1.469325286,2.073398719,2.685562967,3.301684906,3.920036274,4.539789000,5.160504554,5.781933044,6.403924081,7.026383246,7.649249090,8.272480151,8.896047187,9.519928280,10.14410561,10.76856326,11.39328562,12.01825636];
for n=1:20
f(1,1,n)=(((j(1,n)^2)-(h(1)*h(2)))^2)+(j(1,n)^2)*((h(2)+h(1))^2);
f(1,2,n)=((j(1,n)^2)+(h(1)^2))*f(1,1,n);
f(1,3,n)=(h(2)+h(1))*((j(1,n)^4)+((j(1,n)^2)*h(1)*(h(2)+h(1)))+((h(1)^3)*h(2)));
A(1,n)=(2*f(1,1,n))/(f(1,2,n)+f(1,3,n));
B(1,n)=sin(j(1,n))-(h(1)/j(1,n))*(cos(j(1,n))-1);
C(1,n)=A(1,n)*B(1,n);
C(2,n)=(2/(5.027*j(2,n)))*((besselj(1,5.027*j(2,n)))/(((besselj(0,5.027*j(2,n)))^2)+((besselj(1,5.027*j(2,n)))^2)));
end
syms z r t
Z=0
R=0
for n=1:20
Z=C(1,n)*(exp(-(j(1,n)^2)*t))*(j(1,n)*cos(j(1,n)*z)+h(1)*sin(j(1,n)*z))+Z;
R=C(2,n)*(exp(-(j(2,n)^2)*t))*besselj(0,j(2,n)*r)+R;
end
teta=(Z*R);
T=((38)*teta)+295;
V=subs(teta,[z r],[0.5 0]);
ezplot(V)
the first code works correctly but the second one errors for ezplot! the most important problem that happens in second code that is different from 1st one, is that when the value of z substitutes, V become NaN! not a sym fun. but in first code it becomes to a sym fun.
help me if you know the answer. best regards

Risposte (0)

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by