Partial Derivative and its roots
Ältere Kommentare anzeigen
Dear Matlab Gurus
I want to calculate the symbolic partial derivative of a function w.r.t to 'a' and 'b'. The function is
f=n*a*b*(1-b)*p*h^2*g^2)/(n*a*b*g^2*d*r^2+(1-a)*(1-b)*d*e*s^2)
Further more I also want to simplify and calculate the roots of both variable 'a' and 'b'. Actually I want to find the optimal point expression for both 'a' and 'b'. My code is
syms a
syms b
syms n
syms p
syms h
syms g
syms d
syms e
syms r
syms s
f=inline('(n*a*b*(1-b)*p*h^2*g^2)/(n*a*b*g^2*d*r^2+(1-a)*(1-b)*d*e*s^2)','a','b');
diff(diff(f(a,b),a),b)
however, the above code generates the following errors
Error using inlineeval (line 15)
Error in inline expression ==> (n*a*b*(1-b)*p*h^2*g^2)/(n*a*b*g^2*d*r^2+(1-a)*(1-b)*d*e*s^2)
Undefined function or variable 'n'.
Error in inline/subsref (line 24)
INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr, INLINE_OBJ_.expr);
Error in test (line 12)
diff(diff(f(a,b),a),b)
Any kind of help is highly appreciated.
P.S: I have the symbolic math toolbox installed.
Regards
Akzeptierte Antwort
Weitere Antworten (1)
Torsten
am 28 Okt. 2015
Why do you calculate diff(diff(f,a),b) ? Just for testing ?
syms a b n p h g d e r s
[sol_a,sol_b]=solve([diff(n*a*b*(1-b)*p*h^2*g^2)/(n*a*b*g^2*d*r^2+(1-a)*(1-b)*d*e*s^2,a)==0,diff(n*a*b*(1-b)*p*h^2*g^2)/(n*a*b*g^2*d*r^2+(1-a)*(1-b)*d*e*s^2,b)==0],[a,b])
Best wishes
Torsten.
4 Kommentare
Ali Akber
am 28 Okt. 2015
Torsten
am 28 Okt. 2015
Try this:
syms a b n p h g d e r s
[sol_a,sol_b]=solve([diff(n*a*b*(1-b)*p*h^2*g^2/(n*a*b*g^2*d*r^2+(1-a)*(1-b)*d*e*s^2),a)==0,diff(n*a*b*(1-b)*p*h^2*g^2/(n*a*b*g^2*d*r^2+(1-a)*(1-b)*d*e*s^2),b)==0],[a,b])
Best wishes
Torsten.
Ali Akber
am 28 Okt. 2015
Torsten
am 28 Okt. 2015
Consult your documentation on how to use the solve-command in release 2011b.
Best wishes
Torsten.
Kategorien
Mehr zu Conversion Between Symbolic and Numeric finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!