-2

i have write this program but it's not working

function xprime = exh(t,z)
xprime = [z(2);
          30*z(3) - 40*z(1); 
          z(4);
          30*z(1)+30*z(5)-60*z(3);
          z(6);
          30*z(3)-40*z(5)];

tspan=[0,200];
Z0=[0.05 0.04 0.03];
[t,z] = ode45('exh',tspan,Z0);
plot(t,z)
CroCo
  • 5,531
  • 9
  • 56
  • 88

1 Answers1

1

Your system has dimension 6, your initial value has dimension 3, this can not work, the dimensions have to be the same.

In other words, you need not only the initial positions but also the initial velocities for a system of order 2.

Lutz Lehmann
  • 25,219
  • 2
  • 22
  • 51