matlab function

1 次查看(过去 30 天)
LIU WEIHUA
LIU WEIHUA 2012-3-26
when I use the function below:
syms x y z
f = [x*y*z; y; x + z];
v = [x, y, z];
R = jacobian(f, v);
the result is :
R =
[ y*z, x*z, x*y]
[ 0, 1, 0]
[ 1, 0, 1];
However, I want to assign the real number to x y z, for example, x=1 y=2 z=3 , and get the real value of the R.How can I do this?
Thank you very much!

采纳的回答

Walter Roberson
Walter Roberson 2012-3-26
When you say "real value of R", do you mean as opposed to the imaginary part? If so, then use real (R) -- but don't expect the output to change much.
If when you say "real value of R", you are talking about the R that would result for particular values of x, y, and z, then you can subs() values in to R:
subs(R, {x, y}, {11.3, pi/42})
But if you are evaluating repeatedly you might want to use matlabFunction:
Rf = matlabFunction(R, x, y, z);
Then Rf would be a function handle that would accept 3 parameters and return the appropriate matrix.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by