I want to solve 7 pde's that are functions of time, radius(j) and length(i). I used the method of lines and converted them to a system of odes in time and it becomes something like this:$$dy/dt=((y(i,j)-y(i,j-1))\Delta{r} )+(y(i,j)-y(i-1,j))\Delta{x}$$I define all of the equations in one function in MATLAB. This is my function:$$dy/dt=f(t,y)$$and then I solve those ode's by using ode15s solver. Now one of the boundary conditions is an algebraic equation that should be in this function too. It is an algebraic equation of the form: $$y=f(r,x)$$so I think if equations have the same appearance, I can write all of them in one function. So I write it in this way: $$(10^{-10})\times dy=y-f(r,x)$$I put this small coefficient to eliminate $dy$ effect and solve algebraic equation, but MATLAB cant solve it. How can I define this function?
How can i define algebraic equation in differential function in MATLAB?
matlab;ode;method of lines;nonlinear algebra
Your question is not quite clear, but if your problem is roughly analogous to$\frac{d\mathbf{x}}{dt}=\mathbf{f}[\mathbf{x},y]$ , $g[\mathbf{x},y]=0$then you just need to use a mass matrix in your call to ode15s. This is how you tell Matlab that you have an algebraic equation.That is, in Matlab pseudo-code you can express the above aseye(n)*dxdt = f(x,y) % n=length(x)  0   *dydt = g(x,y) % y is a scalarwhich you would pass to ode15s as a single systemM*dzdt = h(z) % here z=[x;y] , h=[f;g], and M = blkdiag(eye(n),0)    The particular syntax will depend on you specific system. The relevant part of the help in the above link begins where it says:If the mass matrix M is singular, then M(t,y)y = f(t,y) is a system of differential algebraic equations.(Edit: The explanation here may be more clear.)