フィルターのクリア

Jacobian function and derivative that is a fraction

1 回表示 (過去 30 日間)
Rick
Rick 2015 年 9 月 26 日
コメント済み: Walter Roberson 2015 年 9 月 27 日
Hello,
I'm trying to use the Jacobian function to find the matrices to linearize my two equations
However, when I try and take the partial derivative with respect to (F/V) for matrix B, then I get an error.
syms CA CB F V CAi k1 k2 k3
f1 = (F/V)*(CAi-CA)-k1*CA-k3*CA^2;
f2 = -(F/V)*CB + k1*CA - k2*CB;
A = jacobian([f1; f2], [CA CB]);
B = jacobian([f1; f2], [F/V CAi])
Error using mupadmex
Error in MuPAD command: The variable is invalid. [stdlib::diff]
Error in sym/jacobian (line 34)
Jsym = mupadmex('symobj::jacobian',F.s,x.s);
I'm wondering what I can do to fix this. Thanks

採用された回答

Matt J
Matt J 2015 年 9 月 26 日
編集済み: Matt J 2015 年 9 月 26 日
Although the documentation doesn't say so, I would guess that the Jacobian cannot be taken with respect to a symbolic expression like F/V. It has to be with respect to a named variable. So, replace F/V with its own variable like below,
syms CA CB Fv CAi k1 k2 k3
f1 = (Fv)*(CAi-CA)-k1*CA-k3*CA^2;
f2 = -(Fv)*CB + k1*CA - k2*CB;
A = jacobian([f1; f2], [CA CB]);
B = jacobian([f1; f2], [Fv CAi])
  2 件のコメント
Rick
Rick 2015 年 9 月 26 日
That worked, thank you
Walter Roberson
Walter Roberson 2015 年 9 月 27 日
Although that works in this case, in general you need to do the change of variables after you construct the expression. For example,
diff(sin(x)^2 + (1-y^2), sin(x))
would seem to have the obvious change
diff(sinx^2 + 5*(1-y^2), sinx)
but if y happens to be cos(x) then your original expression is
diff(sin(x)^2 + 5*(1-cos(x)^2), sin(x))
or
diff(sin(x)^2 + 5*sin(x)^2, sin(x))
or
diff(6*sin(x)^2, sin(x))
and then it is safe to do the change of variables.
Therefore if you have diff(f(x), v(x)) for some functions f(x) and v(x), you need to use something like
diff(subs(f(x), x, solve(Vx = v(x),x)), Vx)

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by