solving system of non linear equations

sym x;
sym a1;
sym a2;
sym a3;
sym a4;
sym u1;
sym u2;
sym u3;
sym u4;
u=a1+a2*x+a3*(x^2)+a4*(x^3);
l=1;
eqn=[subs(u,x,0)-u1==0,subs(diff(u(x),x),x,0)-u2==0,subs(u,x,l)-u3==0,subs(diff(u(x),x),x,l)-u4==0];
[a1, a2, a3, a4]=solve(eqn);
It is showing error.Is there anything wrong with the code?

 Respuesta aceptada

Walter Roberson
Walter Roberson el 15 de Nov. de 2016
Those "sym" need to be "syms"
syms x a1 a2 a3 a4 u1 u2 u3 u4
also, you need to define u as
u(x) = a1+a2*x+a3*(x^2)+a4*(x^3);

3 comentarios

naveen badri
naveen badri el 15 de Nov. de 2016
Editada: Walter Roberson el 15 de Nov. de 2016
I is executed,but the equation is not solved.
After executing when i am giving a1 as input in command window, it is giving just a1 but not the value of a1 after solving. This is the code.
syms x a1 a2 a3 a4 u1 u2 u3 u4;
u(x)=a1+a2*x+a3*(x^2)+a4*(x^3);
l=1;
eqn=[subs(u,x,0)-u1==0,subs(diff(u(x),x),x,0)-u2==0,subs(u,x,l)-u3==0,subs(diff(u(x),x),x,l)-u4==0];
[a1, a2, a3, a4]=solve(eqn);
[a1, a2, a3, a4]=solve(eqn, a1, a2, a3, a4);
It was solving for the u variables by default.
naveen badri
naveen badri el 15 de Nov. de 2016
thank you sir

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Symbolic Math Toolbox en Centro de ayuda y File Exchange.

Preguntada:

el 15 de Nov. de 2016

Comentada:

el 15 de Nov. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by