From: Konda srinivasarao on
clear all
syms Er r xa ya a b
N=10;% number of times
NR=0;
nr=0;
m=0;
M=0;
xa=zeros(1,10);
ya=zeros(1,10);
% E=zeros(1,10);
% r0=zeros(1,10);
gama=0.05;
% x=1;
for x=1:10

%recureence ralation for an
r0=1/sqrt(gama);
a0=1;
a(1)=a0/(2*abs(m)+1);
a(2)= (2*a(1)-Er*a0)/((4*abs(m)+4)*2);
a(3)=(2*a(2)-Er*a(1))/((4*abs(m)+6)*3);
a(4)=(2*a(3)-Er*a(2)+(1/8)*gama^2*a0)/((4*abs(m)+8)*4);
for i=5:N
a(i)=(2*a(i-1)-Er*a(i-2)+(1/8)*gama^2*a(i-4))/((4*abs(m)+2*i)*i);
end
% first wave function
phsi1=a0;
for i=1:N
phsi1=phsi1+a(i)*r^i;
end
phsi1=r^abs(m)*phsi1;
phsi1=simplify(phsi1);
phsi1d=diff(phsi1);

%recurrence relation for bn
b0=1;
b(1)=1;
s=Er/gama-1;
b(2)=2*b(1)-(s^2-m^2)*b0;
for i=3:N
b(i)=2*b(i-1)- ((s-i+2)^2-m^2)*b(i-2);
end
phsi2=b0;
for i=1:N
phsi2=phsi2+b(i)*exp((-1/8)*gama*r^2)*r^(-i);
end
phsi2=exp((-1/8)*gama*r^2)*r^s*phsi2;
phsi2=simplify(phsi2);
phsi2d=diff(phsi2);

r0=1/sqrt(gama);
shi1=simplify(subs(phsi1,r,r0));
shi1d=simplify(subs(phsi1d,r,r0));
shi2=simplify(subs(phsi2,r,r0));
shi2d=simplify(subs(phsi2d,r,r0));
eq=shi1*shi2d-shi2*shi1d;
eq=simplify(eq);
result=solve(eq);
result=vpa(result,length(result));
k=length(result);
if(k==1)
Er=result;
else
result=real(double(result));
for p=1:k
if(result(result(p)>0))
Erv=result(p);
end;
end
Er=min(double(Erv));
end;
Er;
Ec=(2*NR+abs(M)+1)*gama;
E0=(2*nr+abs(m)+1)*gama;
E=Ec+Er;
xa(x)=r0;
ya(x)=E/gama;
gama=gama+0.1;

end

E
% plot(xa,ya,'-')


for this the error is
The following error occurred converting from sym to double:
Error using ==> sym.double at 29
DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use the VPA function instead.

Error in ==> w4 at 77
ya(x)=sym('E')/gama;

and how i obtaining the minimum positive value form equation
From: Steven Lord on

"Konda srinivasarao" <08pcmt13(a)gmail.com> wrote in message
news:hk4h01$qpn$1(a)fred.mathworks.com...

Copying from the bottom of your post, the error you're receiving is:

> for this the error is The following error occurred converting from sym to
> double:
> Error using ==> sym.double at 29
> DOUBLE cannot convert the input expression into a double array.
> If the input expression contains a symbolic variable, use the VPA function
> instead.
>
> Error in ==> w4 at 77
> ya(x)=sym('E')/gama;

*snip part of the code*

> ya=zeros(1,10);

*snip part of the code*

> ya(x)=E/gama;

E/gama is a symbolic expression that includes a symbolic variable, isn't it?
If so, the line above attempts to store that symbolic expression in an
element of a _double_ array (you preallocated it to be a 1-by-10 double
array on the first line I quoted above) and in order to do that, MATLAB
would have to convert the symbolic expression into a double array. However,
since the expression contains a symbolic variable, MATLAB can't convert
it.to a double array directly. Use SUBS to substitute values for the
symbolic variables into the expression before trying to store it in the
double array, or make ya a symbolic array:

ya = sym(zeros(1, 10));

so that no conversion if necessary. If you use the latter suggestion, you
WILL still need to substitute values into ya (and xa if necessary) before
passing them into PLOT.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


 | 
Pages: 1
Prev: project
Next: Setting object propeties via mex