How to stop MatLab from automatically substituting in variables?

16 vues (au cours des 30 derniers jours)
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,

Réponse acceptée

Sai Sri Pathuri
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

Plus de réponses (0)

Catégories

En savoir plus sur 3-D Volumetric Image Processing dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by