Question #7429

The initial conditions are y(t = 0) = 2 and dy(t = 0)/dt = 0. The file VdP with the resulting right hand side
has been coded up for the given equation. Solve the equation for t = [0 : 0.01 : 32] using ode45. Is this the right code to solve for y(t)?
y0 = [2; 0];
[t,y1]=ode45(@VdP,[0:0.01:32],y0);
A4 = y1(:,1);

Expert's answer

Matlab

The initial conditions are y(t=0)=2y(t = 0) = 2 and dy(t=0)/dt=0dy(t = 0)/dt = 0. The file VdP with the resulting right hand side has been coded up for the given equation. Solve the equation for t=[0:0.01:32]t = [0:0.01:32] using ode45. Is this the right code to solve for y(t)y(t)?


y0 = [2; 0];
[t,y1]=ode45(@VdP,[0:0.01:32],y0);
A4 = y1(:,1);


Yes, this code is right if code in the VdP-file is correct.

Here is an example of these two files for solving simple equation (with 0 initial cond.):


d2udt2=1\frac{d^2 u}{dt^2} = 1


VdP:


function du=VdP(t,u)
du=zeros(2,1);
du(1)=u(2);
du(2)=1;


Solution:


[t,h]=ode45(@VdP,[0 300],[0,0]);
Solution = h(:,1)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS