I am going to simplify the problem out of context as I believe this will be easier to understand, obviously I will be corrected if this is actually unhelpful.
There's 3 m files. Main, secondfun, thirdfun.
In main I have defined an 8 element vector i.e.
vector=[var1 var2 var3 var4 var5 var6 var7 var8]
In main I then call the second function with vector as one of the inputs i.e.
[out1, out2]=secondfun(in1, in2, in3, vector)
Where secondfun m file has secondfun(x,y,z,vector):
and thirdfun, thirdfun(~,vector) has:
So running this I get the error that on the second line in thirdfun: Index exceeds matrix dimensions.
I narrowed this error down to where I'm using ode45 in secondfun. Before that line the vector function is a 8 element row vector as it should be. After that line it's turned into y0 only (3 element column vector), i.e. it's being passed into secondfun fine as far as I understand but I don't understand where or how it's being redefined as that?
Any advice on this would be much appreciated.