Skip to main content
added 4 characters in body
Source Link
Anton Menshov
  • 8.7k
  • 7
  • 41
  • 94

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 as

eye(n)*dxdt = f(x,y) % n=length(x)
  0   *dydt = g(x,y) % y is a scalar

which you would pass to ode15s as a single system

M*dzdt = h(z) % here z=[x;y] , h=[f;g], and M = blkdiag(eye(n),0)    

The particular syntax will depend on youthe specific system. The relevant part of the help in the above link begins where it says: "If the mass matrix M$M$ is singular, then M(t,y)y′ = f(t,y)$M(t,y)y′ = f(t,y)$ is a system of differential algebraic equations."

(Edit: The explanation here may be more clear.)

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 as

eye(n)*dxdt = f(x,y) % n=length(x)
  0   *dydt = g(x,y) % y is a scalar

which you would pass to ode15s as a single system

M*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.)

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 as

eye(n)*dxdt = f(x,y) % n=length(x)
  0   *dydt = g(x,y) % y is a scalar

which you would pass to ode15s as a single system

M*dzdt = h(z) % here z=[x;y] , h=[f;g], and M = blkdiag(eye(n),0)    

The particular syntax will depend on the 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.)

added 116 characters in body
Source Link
GeoMatt22
  • 336
  • 2
  • 6

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 as

eye(n)*dxdt = f(x,y) % n=length(x)
  0   *dydt = g(x,y) % y is a scalar

which you would pass to ode15s as a single system

M*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.)

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 as

eye(n)*dxdt = f(x,y) % n=length(x)
  0   *dydt = g(x,y) % y is a scalar

which you would pass to ode15s as a single system

M*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."

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 as

eye(n)*dxdt = f(x,y) % n=length(x)
  0   *dydt = g(x,y) % y is a scalar

which you would pass to ode15s as a single system

M*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.)

Source Link
GeoMatt22
  • 336
  • 2
  • 6

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 as

eye(n)*dxdt = f(x,y) % n=length(x)
  0   *dydt = g(x,y) % y is a scalar

which you would pass to ode15s as a single system

M*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."