Doubt regarding ode45 plotting

Dear Friends,
I need to plot ABS(B(1)) Vs delk in the following program code. How can i include delk variable in the ode45 function calling line.

 Respuesta aceptada

Torsten
Torsten el 28 de En. de 2015

0 votos

Please make more clear what you try to plot.
As far as I can see, delk is a model parameter (scalar).
B is a vector (solution at different times).
You can't plot a vector over a scalar.
I guess you want to plot different solutions B over time for different values of delk.
For this puropse, you have to generate different solutions B (e.g. in a loop in which you call ODE45 several times for changing values of delk).
Best wishes
Torsten.

9 comentarios

Pavan Kumar
Pavan Kumar el 28 de En. de 2015
Editada: Pavan Kumar el 28 de En. de 2015
Hi Torsten.
Thanks for your answer.
In my program, delk is a function of kp,ks and ki which are in turn dependent on Lp,Ls and Li respectively. So,delk is unique for each value of Ls,Lp and Li and will be continous for a range of Ls as shown.This inturn makes Abs(B(1)) continous function of Ls.I need to plot Abs[B(1)]^2 vs delk in my program
Torsten
Torsten el 28 de En. de 2015
Again my question:
For each value of L_s, you get a function B(1) over the interval [0 3] in your example above.
How do you want to plot a function (B(1)) over a scalar (L_s) ?
Best wishes
Torsten.
Pavan Kumar
Pavan Kumar el 28 de En. de 2015
Torsten,
As mentioned above,Change in Ls changes delk which inturn changes B(1).
It would be a 3-D plot with abs[B(1)],Z1 and delk on each of the axis.
Pavan Kumar
Pavan Kumar el 29 de En. de 2015
Hii Torsten,
I don't know if i am right or wrong.But, i followed the avove code for constant delk and got right results so i am following the same for variable delk.
Do advise me.
Pavan
Torsten
Torsten el 29 de En. de 2015
The code you show in the above picture will not run with MATLAB.
Since delk in function DFG789 is a vector, dB will also be a vector.
But dB(1) is a scalar which gives a dimension mismatch.
Best wishes
Torsten.
Pavan Kumar
Pavan Kumar el 29 de En. de 2015
Is it possible to use any other function in matlab in this situation?
Torsten
Torsten el 29 de En. de 2015
I already gave you the solution for this problem:
Call ODE45 in a loop in which you calculate the solution for B(1) for several values of delz.
Delk=[1:20];
for i=1:20
delk=Delk(i)
[Z1,B] = ode45(@(t,x)DFG789(t,x,delk),[0 3],[(0.1) 0 1]);
Z1_complete(i,:,:)=Z1(:,:);
end
Best wishes
Torsten.
Pavan Kumar
Pavan Kumar el 29 de En. de 2015
Thanks a lot..Will try it and come back to you
Pavan Kumar
Pavan Kumar el 2 de Feb. de 2015
Hii Torsten,
your advise really helped. Thanks a trillion bro...
Pavan

Iniciar sesión para comentar.

Más respuestas (1)

Sara
Sara el 27 de En. de 2015
ode45(@(t,x)DFG789(t,x,var_1),.....
Then the function becomes:
function dB = DFG789(Z1,B,var_1)

1 comentario

Pavan Kumar
Pavan Kumar el 28 de En. de 2015
Editada: Pavan Kumar el 28 de En. de 2015
Hii Sara, Thanks for the advise.
I made the following changes
[Z1,B] = ode45(@(t,x)DFG789(t,x,delk),[0 3],[(0.1) 0 1],delk); and
function dB = DFG789(Z1,B,delk)
However, when i try to execute
plot(delk,abs(B(:,1)).^2);
i get the following errors. What can i do?

Iniciar sesión para comentar.

Categorías

Más información sobre Mathematics en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 27 de En. de 2015

Editada:

el 3 de Feb. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by