How to solve a matrix of two symbolic variables using in-built function ode113??

  1. I have a matrix B_mat of order (n+1,n+1), whose elements are computed by integrating functions of z variable.
  2. I have a matrix E_mat whose elements are functions of x only, after integrating with respect to z.
  3. F_mat = inv(B_mat) *E_mat
  4. Y is a vector of unknown variables and
  5. Fxy_mat = F_mat*y;
I am solving this Fxy_mat with ode113 in my code but didn't get success.

2 Comments

It would be easier to follow if you directly present the ODE system you are trying to solve and the problems you encounter.
Best wishes
Torsten.
Thank you Torsten for your quick response!
Since the ode system is constructing in the program, I am attaching the MATLAB code Query.m
When I run this program, I got the following errors:
Error using odearguments (line 110) Inputs must be floats, namely single or double.
Error in ode113 (line 113) [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in Query (line 81) sol=ode113( @(x,y) Fxy_mat,[0 1],A_initial,odeset('abstol',1e-7,'reltol',1e-7));

Sign in to comment.

 Accepted Answer

You do not solve matrices of symbolic variables using ode113. The ode* functions are only for numeric work.
If you have symbolic differential equations that you want to simulate numerically, then follow the steps at odeFunction()

8 Comments

Thank you so much Walter Roberson!
Can you solve system of 100 symbolic differential equations using odeFuctions()?
The limit for the steps shown for odeFunction are memory and time. The step that concerns me the most in that respect is the step
f = M\F;
which I worry could be quite expensive for larger systems. In the example given in the documentation, M is essentially just a permutation matrix with a negation thrown in; those are not difficult to handle with a small program, but I worry about the general operation.
okay. When I use
>>ode15s(Fxy_vec,[x; y], [0 10], A_initial)
Then, also the same error comes:
Undefined function 'exist' for input arguments of type 'sym'.
The Fxy_vec should be the result of using odeFunction, and the timespan [x;y] should be numeric values, not symbolic values. It would be much more typical to have the times in a row vector than in a column vector; I would need to check to see if using a column vector tspan is permitted. The initial values [0 10] you have given as a row vector; note that those will become a column vector when passed in to the function, but passing a row vector here is common and permitted. A_initial is in the options slot; ode15s is going to check whether it is a struct or not, and if it is not a struct is going to treat it as an extra parameter to pass to the function.
I would suggest to you that you missed a step:
ode15s( odeFunction(Fxy_vec, [x;y]), [0 10], A_initial )
Actually, I am using 2014 version of MATLAB. In which, if I use the following commands:
odefun = odeFunction(Fxy_vec, [x ; y]);
ode15s(odefun, [0 10], A_intial);
Following error comes:
Undefined function 'odeFunction' for input arguments of type 'sym'.
Error in check (line 116)
odefun = odeFunction(Fxy_vec,[x; y]);
odeFunction was added in R2015a. Time for you to upgrade.
ok, thank you so much Walter Roberson for your kind help.
I have downloaded the 2017 version of MATLAB. But still, I am facing the problem with "odeFunction". (These two lines are followed by the above Matlab script "Query.m")
odefun = odeFunction(Fxy_vec, vars);
ode15s(odefun, [0,1], A_initial)
Error using mupadengine/feval (line 166)
Variables must be specified by univariate function calls.
Error in sym/odeFunction (line 118)
A = feval(symengine, 'daetools::odeFunction', expr, vars, params{:});
Error in odefn (line 123)
odefun = odeFunction(Fxy_vec, vars);

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!