how to create a symbolic derivative of f(r(x,y),theta(x,y)) and evaluate it
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Marko
am 29 Jan. 2021
Kommentiert: Marko
am 30 Jan. 2021
Hello Community,
i have some more or less complicated funtions, e.g. a simple one:
f(r,theta) = r*(pi*cos(theta)+2*sin(theta));
x = x0 +r*cos(theta);
y = y0 +r*cos(theta);
and I need the symbolic derivative of f with respect to x any y: d f(r(x,y),theta(x,y)) / dx = ....
my code look like this:
syms f f1 f2 r theta x x0 y0 y pi
f = r*(pi*cos(theta)+2*sin(theta));
f1 = x == x0 + r*cos(theta);
f2 = y == y0 + r*sin(theta);
dr_dx = diff(solve(f1,r),x)
dtheta_x = diff(solve(f1,theta),x)
dr_dy = diff(solve(f2,r),y)
dtheta_y = diff(solve(f2,theta),y)
df_r = diff(f,r)
df_theta = diff(f,theta)
but how i could create the desired derivative..
0 Kommentare
Akzeptierte Antwort
David Durschlag
am 29 Jan. 2021
Let's break down the operations required:
First, solve for theta and r in terms of x and y:
theta_r = solve([x == x0 + r*cos(theta), y == y0 + r*sin(theta)], [theta, r]);
theta_r will be a struct with possible substitutions for theta and r as its properties.
Second, choose the substitutions (in this case, the first ones):
theta_r_subs = [theta_r.theta(1), theta_r.r(1)];
Third, perform the substitution:
fxy = subs(f, [theta, r], theta_r_subs);
Fourth, differentiate:
df_x = diff(fxy, x);
df_y = diff(fxy, y);
Further solutions can be obtained by choosing different substitutions.
--David
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Assumptions finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!