I try to substitute long expressions with short variables. Here I want to replace 3*b^2
with d
. After that, I want to evaluate the expression a
with numeric values. But somehow Matlab does not recognize if I assign a value to b
and instead refers to the UNKNOWN variable d
. How do I subsitute with d
and also tell Matlab to compute d
as a function of b
?
syms a b c d
a = 3*b^2 + c;
a = subs(a, 3*b^2, d) % substitute long term
subs(a,{b,c},{2,3}) % Returns ans = d + 3, But I want it to return ans = 15
question from:
https://stackoverflow.com/questions/65864027/subs-in-matlab-symbolic-toolbox-does-not-evaluate-values 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…