"Torsten" wrote in message <firstname.lastname@example.org>... > "Jan Simon" wrote in message <email@example.com>... > > Dear Marc, > > > > > > [T,Y]=ode15i(@(t,y) Differential_Equation_Solver(t,y,K,M,C,P),tspan,y0,yp0); > > > > > > > > function dydt=Differential_Equation_Solver(t,y,K,M,C,P) > > > > dydt(1) = y(2); > > > > dydt(2) = M\(P-C*y(2)-K*y(1)); > > > > end > > > > > > > > > You can not pass the K,M,C,P variables into the solver. See "nested functions" or the documentation on "passing other variables into functions" with the Matlab ODE solvers. > > > > It is valid and recommended to pass constants by using anonymous functions, see: > > http://www.mathworks.com/matlabcentral/answers/1971 > > > > The problem is the yp0. This is another method to pass constants to the function to be integrated. But the function Differential_Equation_Solver does not accept further parameters in the inputs. So omitting yp0 as input to ODE45 should solve the problem, as mentioned above. > > > > Kind regards, Jan > > Two further errors in the code: > 1. The OP tries to solve 152 ODEs, not only 2 as implied by the function Differential_Equation_Solver. > 2. For ODE15i, you will have to supply residuals, not time derivatives. > > Best wishes > Torsten.
Yeah, this threw me off. I missed the anonymous function call.