just need help with B. i have so far: function dz = prob3(t,z) z = zeros(4,1); d
ID: 2970923 • Letter: J
Question
just need help with B. i have so far:
function dz = prob3(t,z)
z = zeros(4,1);
dz(1) = z(2);
dz(2) = -0.0673*z(2)*sqrt(z(2)^2+z(4)^2);
dz(3) = z(4);
dz(4) = -9.81-0.0673*z(2)*sqrt(z(2)^2+z(4)^2);
when i tried running the ode45 i got an error:
>> [t,z] = ode45(@prob3,[0 5],[0 134 0 0]);
Error using odearguments (line 91)
PROB3 must return a column vector.
Error in ode45 (line 114)
[neq, tspan, ntspan, next, t0, tfinal,
tdir, y0, f0, odeArgs, odeFcn, ...
i don't know what i'm doing wrong.
Explanation / Answer
you did it correctly, but there is one mistake.
In the second line of the prob3 script you wrote z=zeros(4,1)
it should be dz=zeros(4,1).
This is because your returning vector is dz but not z. So you should initialize dz but not z.
Everything else is correct.
the command for plotting y vs x is
plot(z(:,1),z(:,3));
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.