Hi all,
I am trying to solve quite an ODE that I have formed in my attempt to model the removal of a particle from a thin film. In order to solve this, I am trying to make use of the "odeToVectorField" function in order to break down the second order equation into two first order ODE's.
My script seems to work perfectly, where I can form a MATLAB function of the two first order ODE's, however this is unable to be solved when I call ODE45. I am presented with the following error messages:
Index exceeds matrix dimensions.
Error in symengine>makeFhandle/@(Y,t)[Y(2);(Y(2).*(-6.136363636363637e3))./Y(1)+9.810000000000001]
Error in odearguments (line 87) f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 113) [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, …
Error in furthertests (line 16) sol = ode45(M,[0 20],[1 0]);
I am really not sure why this is occuring. Here is the script that I am currently running:
clc;clear; D0 = 0.1*10^-9; R = 1*10^-6;m = (4/3)*pi*(R^3)*1100; mew = 1.5; F0 = m*9.81; syms y(t) eqn = m.*diff(y,2)== F0 - 6.*pi.*mew.*(R.^2).*(1./y).*diff(y); V = odeToVectorField(eqn)%This breaks down the second order ODE into two separate first order ODE's
M = matlabFunction(V,'vars',{'Y','t'})sol = ode45(M,[0 20],[1 0]);fplot(@(t)deval(sol,t,1), [0, 20])
Apologies for the dodgy spacing in my script, I couldn't figure out how to space it properly on this forum.
Any help you could give with this would be much appreciated.
Cheers.
Best Answer