How to convert different variables into one unified variable in a function?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hoang Nam
il 12 Set 2020
Commentato: Hoang Nam
il 12 Set 2020
Hello I'm a newbie with matlab. Thanks for reading this post.
So I have function f (x,y,z,r) = (x^2 + y^2 +2z)*r
Then I also have z = (x^2+y^2) +2
and r = sqrt(x^2+y^2)
So how do I convert them all into r ? So that my new function f( r ) only have one variable r
f( r ) = (3*r^2 +4)*r
Thank you so much for taking time skimming through this post.
0 Commenti
Risposta accettata
Walter Roberson
il 12 Set 2020
syms x y z r
z = (x^2+y^2) +2
fxyz = (x^2 + y^2 +2*z)*r %uses definition of z in terms of x y
eqn = r == sqrt(x^2+y^2)
rx = solve(eqn, x) %define x in terms of r
fr = simplify(subs(fxyz, x, rx)) %substitute definition of x. Simplify
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Matrices and Arrays in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!