I'm trying to call a function using ode45 from another script file and I am passing in an matrix A. Matlab throws an error and says it can't access the matrix because it is empty. So here's the function code:
function out = test(t, E, A)
global N1 N2 N3;
out = zeros(1,1);
out(1) = N1*(A(1,1)*N1 + A(1,2)*N2 + A(1,3)*N3 + E(1));
And here's the script file:
global N1 N2 N3;
N1 = 10;
N2 = 10;
N3 = 10;
E = [1; 1; 1;];
A = [[0,-1,-1];[1,-1,-0.5];[1,0,-1]];
[t, L] = ode45('test', [0:.01:5], E, A);
When I run this Matlab throws the following error:
Attempted to access A(1,1); index out of bounds because size(A)=[0,0].
Error in ppsystem (line 7)
out(1) = N1*(A(1,1)*N1 + A(1,2)*N2 + A(1,3)*N3 + E(1));
Error in odearguments (line 88)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 114)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in ppsystem_script (line 11)
[t, L] = ode45('test', [0:.01:5], E, A);
I am so confused on why I'm getting this error, any ideas?
Does this work for a modified code?
and the script: