# extract a differential equation solution from struct

7 visualizaciones (últimos 30 días)
Juan Diego Arroyave Florez el 25 de Nov. de 2021
Respondida: Navya Singam el 29 de Nov. de 2021
hello, I need to find a solution of a non-linear differential equation, but the program always indicates that the solution is a structure and I need an explicit solution, the code is.
syms x(t) t
d=1;
a=0.6;
[V]=odeToVectorField(diff(x,2)==-d*diff(x)+x-x^3+a*sin(t));
M = matlabFunction(V,'vars', {'t','Y'});
sol = ode45(M,[-10 100],[0 0])
sol =
struct with fields:
solver: 'ode45'
extdata: [1×1 struct]
x: [1×182 double]
y: [2×182 double]
stats: [1×1 struct]
idata: [1×1 struct]
what should I add or change?
Thank's
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Navya Singam el 29 de Nov. de 2021
Hi,
You can use the "deval" function to evaluate differential equation solution structure. The "deval" function accepts the solution structure and the evaluation points (i.e Evaluation points specifies the points at which you want the value of the solution) as the input arguments. The output of the "deval" function would be the interpolated solution.
y = deval(sol,sol.x) %% to evaluate the solution structure at the sol.x points and 'y' would contain the interpolated solution
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Polymers en Help Center y File Exchange.

R2021a

### Community Treasure Hunt

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

Start Hunting!

Translated by