Substitute for factors of a variable but not the variable itself
이전 댓글 표시
Hi,
I am trying to write a code for a Kalman filter to obtain a symbolic expression. There is an error variable, e. The algorithm calls for the term 1+e^2 = 1, but 1+e ? 1. So, essentially I want to keep e as a variable, but substitute e^2 with 0, or another variable that I can set equal to 0.
There are multiple steps and I cannot just substitute after the last step because if I change e^2 => 0 after the first step the change propagates throughout.
Thank you.
답변 (2개)
Walter Roberson
2011년 3월 31일
In Maple I would use
evalindets(1+e^2, identical(e)^anything, v -> E^op(2, v))
You could investigate the equivalent type-matching facilities in MuPad
Paulo Silva
2011년 3월 31일
a=sym('1+e^2=1');
if a==sym('1+e^2=1') %or strcmp(char(a),'1+e^2=1')
disp('the expressions are equal!!!!')
a=sym('1+0=1');
else
disp('the expressions aren''t equal')
end
댓글 수: 1
Walter Roberson
2011년 3월 31일
But, Paulo, sym('1+e^2=1') should equal sym('e^2+1=1') even though their strings do not compare the same.
카테고리
도움말 센터 및 File Exchange에서 Common Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!