Strange behavior with subs (symbolic substitute)

조회 수: 1 (최근 30일)
Lilllly
Lilllly 2015년 6월 25일
답변: Sean de Wolski 2015년 6월 25일
Hi,
I'm facing a strange problem when using subs (in MATLAB_R2015a)
The following example from the documentation works as it should:
subs(a*b^2, a*b, 5)
ans =
5*b
However, when I am trying slightly different substitutions, the term is not replaced as I would expect it (e.g. resulting in 25*a):
subs(a*b^4, b*b, 5)
ans =
a*b^4
subs(a*b*b*b*b, b*b, 5)
ans =
a*b^4
I'm sure I'm just overseeing something here, but I don't understand wha it doesn't work.
Thanks in advance!

답변 (1개)

Sean de Wolski
Sean de Wolski 2015년 6월 25일
You need to just specify which variable is being substituted and then do the value.
subs(a*b^4, b, sqrt(5))
And for more info.
doc subs

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by