Hello everyone. I have recieved a code in which an expression is called as [t, x]=ode45(@(t,x) example(t,x),tspan,x0); inside of it I have three vectors called u1d, u2d and u3d. I also have
u(1)=interp1(time,u1d,t,'linear');
u(2)=interp1(time,u2d,t,'linear');
u(3)=interp1(time,u3d,t,'linear');
I want to compare u(1) with u1d, u(2) with u2d and u(2) with u3d to see how good the interpolation is. The problem is that if I write
figure
plot(u1d)
inside of example, infinite figures appear.
Can someone please explain to me if it is possible to plot the points of u1d and compare them with the interpolated ones at u(1)?
I have tried to construct
u(1)=interp1(time,u1d,t,'linear');
u(2)=interp1(time,u2d,t,'linear');
u(3)=interp1(time,u3d,t,'linear');
outside of the ode45 function but error messages appear.
Thanks for reading.
Jaime.

5 comentarios

the cyclist
the cyclist el 12 de Nov. de 2019
Can you upload the data in a *.mat file, so we can run and test it ourselves?
Jaime De La Mota Sanchis
Jaime De La Mota Sanchis el 12 de Nov. de 2019
Editada: Jaime De La Mota Sanchis el 12 de Nov. de 2019
When you say data, do you mean u1d, u2d and u3d?
Edit: I will attach one example model and the example function
Daniel M
Daniel M el 12 de Nov. de 2019
You have the vectors time, and u1d (etc) outside of the ode45 call. And you also have the output t from the ode45 call. So, why can't you run an interpolation and compare the two?
Jaime De La Mota Sanchis
Jaime De La Mota Sanchis el 12 de Nov. de 2019
I have tried it your way and it works. Thanks.
Daniel M
Daniel M el 12 de Nov. de 2019
I will move it to an Answer then.

Iniciar sesión para comentar.

 Respuesta aceptada

Daniel M
Daniel M el 12 de Nov. de 2019

2 votos

You have the vectors time, and u1d (etc) outside of the ode45 call. And you also have the output t from the ode45 call. So,you can run an interpolation after calling ode45 (not inside).

Más respuestas (0)

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 12 de Nov. de 2019

Comentada:

el 12 de Nov. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by