Hey guys, I need to solve a coupled, simultaneous and implicit system of ODE's. Here's my code and then I'll briefly explain it:
close all
clear all
time_length = 25;
g = 9.8;
rho0 = 1.20;
d = 0.22;
m = 0.43;
A = pi*(d/2)^2;
Cd = 0.3;
Cl = 0.3;
Sx = 1;
Sy = 1;
Sz = 0;
S = [Sx, Sy, Sz];
odex = @(t,x,y,z) -Cd*(A/(2*m))*rho0*sqrt(x(2).^2 + y(2).^2 + z(2).^2).*x(2) + Cl*(A/(2*m))*rho0*sqrt(x(2).^2 + y(2).^2 + z(2).^2).*(Sy.*z(2)-Sz.*y(2));
odey = @(t,x,y,z) -Cd*(A/(2*m))*rho0*sqrt(x(2).^2 + y(2).^2 + z(2).^2).*y(2) + Cl*(A/(2*m))*rho0*sqrt(x(2).^2 + y(2).^2 + z(2).^2).*(Sz.*x(2)-Sx.*z(2));
odez = @(t,x,y,z) -g-Cd*(A/(2*m))*rho0*sqrt(x(2).^2 + y(2).^2 + z(2).^2).*z(2) + Cl*(A/(2*m))*rho0*sqrt(x(2).^2 + y(2).^2 + z(2).^2).*(Sx.*y(2)-Sy.*x(2));
W = @(x,y,z) [x(1);x(2);y(1);y(2);z(1);z(2)];
dxyz = @(t,x,y,z) [x(2);odex;y(2);odey;z(2);odez];
[T,W] = ode45(dxyz,linspace(0,time_length,1e4),[0,30/sqrt(2),0,0,30/sqrt(2)]);
So basically:
The notation is as follows:
x(1) = x,
x(2) = derivative of x = dx/dt = vx,
odex = second derivative of x = derivative of vx = d2x/dt2 = d(vx)/dt = dx(2)/dt = ax. Same for y and z.
Horrible equations in odex/y/z but basically each depend on the other variables, i.e. odex doesn't only depend on x, but y and z too (and their derivatives)
This last point means I need to solve them via matrix algebra. W is the column matrix that I'm planning to solve for, and dxyz is the column matrix containing the derivatives, i.e. dW/dt = dxyz.
in the ode45 bracket I have 6 initial conditions, corresponding to x(1) -> z(2) in order.
And now when I run it, I get these outputs:
Error using @(t,x,y,z)[x(2);odex;y(2);odey;z(2);odez]
Not enough input arguments.
Error in odearguments (line 88)
f0 = feval(ode,t0,y0,args{:});
Error in ode45 (line 114)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in code (line 37)
[T,W] = ode45(dxyz,linspace(0,time_length,1e4),[0,30/sqrt(2),0,0,30/sqrt(2)]);
It's telling me not enough input arguments, I do not understand. I have everything in there that I need, don't I?
Also I'm getting the idea that all these errors correspond to just the one error, i.e. if I fix the one thing that's wrong, I'll fix it all. Unfortunately, I don't know what to do about it because I don't understand why I'm getting an error.
Any and all help is much appreciated!