Starting with all symbols, ending with mixed symbols and number?
1 次查看(过去 30 天)
显示 更早的评论
I'm performing some symbolic manipulations that result in
(a/b)*x
I'd like to keep 'x' a symbol and substitute numbers for a and b. Unfortunately, the numbers are treated symbolically and a/b doesn't simplify
double((a/b)*x ) doesn't work because x is still a symbol. I'm sure there's a trivial solution that I haven't found.
thanks in advance
0 个评论
采纳的回答
Walter Roberson
2023-12-11
syms a b x
%Expression
y = (a/b)*x;
newy0 = subs(y, [a b], [2 3])
newy1 = subs(y, [a b], sym([2 3], 'd'))
newy2 = vpa(subs(y, [a b], [2 3]))
sympref('FloatingPointOutput', true)
newy4 = subs(y, [a b], [2 3])
0 个评论
更多回答(2 个)
Torsten
2023-12-11
移动:Torsten
2023-12-11
Unfortunately, the numbers are treated symbolically and a/b doesn't simplify
The numbers are not treated symbolically, but as long as x is symbolic, the complete expression is symbolic.
"double" can only be applied to expressions in which all symbolic variables have been substituted by numerical values.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Special Values 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!