Azzera filtri
Azzera filtri

matlab function

1 visualizzazione (ultimi 30 giorni)
LIU WEIHUA
LIU WEIHUA il 26 Mar 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!

Risposta accettata

Walter Roberson
Walter Roberson il 26 Mar 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.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by