How to stop MatLab from automatically substituting in variables?
16 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Corrado Mazzarelli
le 22 Fév 2020
Réponse apportée : Sai Sri Pathuri
le 25 Fév 2020
Hello everyone,
I am wondering how I can get Matlab to not automatically substitute in for the variables in the expressions that follow. For instance, if I wrote this code
syms R w rho
volume = pi * R^2 * w
m= rho * volume
I = (1/2)*m*R^2 + m*e^2
Matlab gives me the following outputs:
volume = pi * R^2 * w
m = pi * R^2 * w * rho
I = (rho * w *pi * R^4)/2 + etcetera
What I want is to have the outputs in terms of the variables that came before them, instead of substituting for the base variables.
So for m I would want it to visually display m = rho * volume, instead of plugging in all the individual variables from the volume equation.
Thank you,
0 commentaires
Réponse acceptée
Sai Sri Pathuri
le 25 Fév 2020
To have the output in terms of volume, you may declare volume as a symbolic variable and define it after defining m.
syms R w rho volume
m = rho * volume
volume = pi * R^2 * w
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur 3-D Volumetric Image Processing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!