How to get eqns datatype from equations in function?
Show older comments
I can use functions like A = equationsToMatrix(eqns) with direct eqns input parameters, e.g.
A = equationsToMatrix([x+y,4*x-2*y]);
but when storing equation systems in functions like
function dZ = ODE(~,z)
x = z(1);
y = z(2);
dZ = [x+y;...
4*x-2*y];
end
I need a reference to the equations in the function so that i could use it like
A = equationsToMatrix([oderef(1),oderef(2)]); %does not work!
oderef(1) and oderef(2) must stand for the 2 equations defined in my function ODE and must be of datatype eqns so that equationsToMatrix can accept these as a parameter. How do I do that? Thanks.
Answers (1)
Walter Roberson
on 24 Sep 2017
Edited: Walter Roberson
on 24 Sep 2017
There is no "eqns" datatype.
It looks to me as if you should be using
odehandle = matlabFunction(A(:), 'vars', {t, [x, y]});
3 Comments
Walter Roberson
on 24 Sep 2017
Is there a particular form that your original ODE must be in?
Do any of the ODE involve second derivative? Are any of them second order? Do any of them involve mass matrices? With your reference to eigenvectors, does that imply you are working with Matrix Differential Equations?
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!