large symbolic matrix substitution
3 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
Star Strider
2014-10-5
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 个评论
Star Strider
2014-10-6
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!