large symbolic matrix substitution
Mostrar comentarios más antiguos
Hi,
I am trying to find a way to efficiently substitute a large symbolic Jacobian matrix with the corresponding numerical values, but all at once. As long as "subs" command becomes extremely slow and the PC becomes idle with no output, I am urgently looking for alternative faster ways. The problem with "matlabFunction" is that it accepts the elements of the "guess matrix" one by one and I don't know how to pass the numerical matrix values all at once to it.
As an example , if
R=sym('R',[1000 1])
RV=matlabFunction (R)
T=ones(1000,1)
then, how to pass "T" into "RV", as a whole?
Any other effective solutions are appreciated, as well. (MATLAB R2012b)
Thanks.
Respuestas (1)
Star Strider
el 5 de Oct. de 2014
I am not certain what you are actually doing, but this works for this example:
syms x y z
f(x,y,z) = 3*x*y + 5*x*z + 7*y*z + 13*x*z;
JF = jacobian(f, [x y z]);
MJF = matlabFunction(JF);
[VX,VY,VZ] = deal(ones(5,1));
JN = MJF(VX, VY, VZ);
The deal function simply takes the single (5x1) column vector created by the ones function and distributes it to [VX,VY,VZ] that are then arguments to the Jacobian anonymous function ‘MJF’.
One item of possible relevance is that ‘R’ should probably be a row vector rather than a column vector.
2 comentarios
Parmida Boroumand
el 6 de Oct. de 2014
Star Strider
el 6 de Oct. de 2014
My pleasure!
It seems that your system is freezing because of the size of the matrices involved. I don’t understand what ‘Def_Mat’, ‘Def_Mat0’, and ‘Equ’ are. It might be best at this point to use matlabFunction to convert everything to numeric and go from there.
Categorías
Más información sobre Assumptions en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!