# Substitute partial differential into symfun

8 Ansichten (letzte 30 Tage)
ludolfusexe am 15 Mai 2024
Kommentiert: ludolfusexe am 16 Mai 2024
Because my actual functions are very complex, I would like to calculate the derivative of nested functions first and then substitute the functions afterwards.
A minimal example looks like this:
syms G(h) h(t) t
Q = G(h)
Q =
dGdt = diff(Q,t) % -> D(G)(h(t)) occurs
dGdt =
% Now define G(h) and derive:
G = h^2;
dGdh = diff(G,h)
dGdh(t) =
How is it possible, to insert the derivative of G with respect to h as the partial derivative?
I tried this, but it is not working:
% dQ_subs = subs(dGdt, D(G), dGdh)
% dQ_subs = subs(dGdt, D(G)(h(t)), dGdh)
I really appreciate any feedback!
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Torsten am 15 Mai 2024
Verschoben: Torsten am 15 Mai 2024
syms G(h) h(t) t
Q = G(h)
Q =
dGdt = diff(Q,t) % -> D(G)(h(t)) occurs
dGdt =
s = children(dGdt)
s = 1x2 cell array
{[D(G)(h(t))]} {[diff(h(t), t)]}
% Now define G(h) and derive:
G = h^2;
dGdh = diff(G,h)
dGdh(t) =
subs(dGdt,s{1},dGdh)
ans =
##### 2 KommentareKeine anzeigenKeine ausblenden
Paul am 15 Mai 2024
Bearbeitet: Paul am 15 Mai 2024
Hi Torsten,
I think it works easier, and perhaps more generally, to define G as a function of its own dummy variable.
syms G(x) h(t) t
Q = G(h);
dGdt = diff(Q,t) % -> D(G)(h(t)) occurs
dGdt =
% Now define G(x) and derive:
G(x) = x^2;
subs(dGdt)
ans =
Slightly more complicated case
G(x) = x^2 + sin(x);
subs(dGdt)
ans =
ludolfusexe am 16 Mai 2024

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Common Operations finden Sie in Help Center und File Exchange

R2022a

### Community Treasure Hunt

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

Start Hunting!

Translated by