How to stop MatLab from automatically substituting in variables?
11 views (last 30 days)
Show older comments
Corrado Mazzarelli
on 22 Feb 2020
Answered: Sai Sri Pathuri
on 25 Feb 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 Comments
Accepted Answer
Sai Sri Pathuri
on 25 Feb 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 Comments
More Answers (0)
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!