Filter löschen
Filter löschen

matlab function

1 Ansicht (letzte 30 Tage)
LIU WEIHUA
LIU WEIHUA am 26 Mär. 2012
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!

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 26 Mär. 2012
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.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by