How do I get warning: Cannot solve symbolically. Returning a numeric approximation instead.

I was trying to solve equations with solve. The code is attached.
sigmaf1=3.34;
ss=linspace(0,sigmaf1);
C0=20;
A=1227;
V0=1;
Vd=2/3;
Vc=1/3;
Cst=2;
Vt=0.0256;
Na=6.02*10^23;
q=1.6*10^-19;
xx=zeros(100,1);
yy=zeros(100,1);
zz=zeros(100,1);
vv=zeros(100,1);
for i=1:100;
syms x y z v
eq1=ss(i)*(10^18)*A*tanh(0.25*x/Vt)-Vd*(10^-3)*(C0-z)*Na;
eq2=2*y-ss(i)*(10^18)*q;
eq3=ss(i)*(10^18)-4*z*Na*v*(10^-9)*sinh(0.5*x/Vt);
eq4=v-0.30316./sqrt(1000.\z);
[X,Y,Z,V]=solve(eq1,eq2,eq3,eq4,x,y,z,v);
xx(i)=X; yy(i)=Y; zz(i)=Z; vv(i)=V;
end
the results shows that the value for xx has complex part. Can anyone help me avoid this problem? Thank you very much!

1 comentario

Please learn to use the "{} Code" button to format your code. I've fixed it once for you.

Iniciar sesión para comentar.

 Respuesta aceptada

As far as solving your problem symbolically versus a numeric solution, there is NO symbolic solution to your problem (thus in terms of radicals.) It is trivial to write such a problem that has no solution. You have done so. Wanting a solution to exist is insufficient unless your name is Harry Potter.
And finally, wanting a real solution to exist, when only a complex solution can be found? Well, this is often no easier. However, today, you may get lucky. When you specify x,y,z,v, add the extra information that you want real solutions.
syms x y z v real
So, for i==2, now you will get:
X =
0.016453816309365066180198046442109
Y =
0.0026989898989898989898989898989899
Z =
19.983567561553008439257294763932
V =
2.1445461019277877405973945497257

Más respuestas (0)

Preguntada:

el 11 de En. de 2017

Comentada:

el 12 de En. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by