Can Yvv and Yuu be embedded in the program
Info
This question is closed. Reopen it to edit or answer.
Show older comments

Can Yvv and Yuu be embedded in the program

The formulas above without Yvv and Yuu Matlab:edit, Then,the following lines between the percent sign (%) copied to m.file, save %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function dx=myfun(t,x) dx(1)=-6*x(2)*x(2)-9; dx(2)=-3*x(1)*x(2)-2*x(3); dx(3)=x(1)*x(2)+x(3)+8; dx=dx(:); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Matlab: x0=[3,-4,2]; t0=0:0.1:10; [t,x]=ode45('myfun',[0,2],x0); plot(t,x) legend('u','v','Y')
7 Comments
Torsten
on 10 Feb 2015
According to your MATLAB code, the third equation reads
u*v+Y+8=Ydot,
not
u*v+Y+8=vdot
Which version is correct ?
Best wishes
Torsten.
Torsten
on 10 Feb 2015
In this case, add equations (2) and (3).
You get
4*u*v + 3Y + 8 = 0,
thus
Y=-4/3*u*v-8/3.
So only solve equations (1) and (2) and calculate Y as
Y=-4/3*u*v-8/3
Best wishes
Torsten.
Lan
on 10 Feb 2015
Torsten
on 10 Feb 2015
function dx=myfun(t,x)
t_array=[0 1 2 3 4 5 6 7 8 9 10];
Y_uu_array=[6 7 4 10 2 3 5 4 9 6 8];
Y_vv_array=[1 5 3 10 11 8 2 6 8 10 3];
Y_uu=interp1(t_array,Y_uu_array,t);
Y_vv=interp1(t_array,Y_vv_array,t);
dx=zeros(2,1);
u=x(1);
v=x(2);
Y=-(4*u*v+8)/3;
dx(1)=-6*v^2-9;
dx(2)=-3*u*v-2*Y-Y_uu-Y_vv;
Best wishes
Torsten.
Torsten
on 11 Feb 2015
Thank you.
One small error in the code I posted:
Replace
Y=-(4*u*v+8)/3;
by
Y=-(4*u*v+8+Y_uu+Y_vv)/3;
Formerly, I used the equations without Y_uu and Y_vv to calculate Y.
Best wishes
Torsten.
Answers (0)
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!