How to tell matlab that y is a function of x; not a constant
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Ayan PATSA
am 7 Mai 2021
Kommentiert: Star Strider
am 8 Mai 2021
I have a function z such that z=xy(x) , [i.e. y is a function of x]. So if I differentiate z with respect to x, I shoud get dz/dx= y+x*(dy/dx). However if I use diff(z,x) in matlab, I get only y [matlab treats y as a constant]. What should I do to define y as a function of x?
syms x y z
z=x*y;
diff(z,x)
ans =
y
0 Kommentare
Akzeptierte Antwort
Star Strider
am 7 Mai 2021
In the initial syms call, declare ‘y(x)’ instead of ‘y’ —
syms x y(x) z
z=x*y;
Dz = diff(z,x) % Create Assignment
Note that now ‘Dz’ is also a funciton of ‘x’, as it should be.
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Assumptions finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!