Substitute for factors of a variable but not the variable itself
Show older comments
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.
Answers (2)
Walter Roberson
on 31 Mar 2011
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
on 31 Mar 2011
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 Comment
Walter Roberson
on 31 Mar 2011
But, Paulo, sym('1+e^2=1') should equal sym('e^2+1=1') even though their strings do not compare the same.
Categories
Find more on Common Operations 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!