Replace powers with a sequence
1 次查看(过去 30 天)
显示 更早的评论
Hello friends!
Consider a binomial symbolic expression like (x-1)^3 and a symbolic vector e of size 3 (e=sym('e',[1 3]) ). Of
course, in my real problem I have 'n' instead of 3 but I just used 3 here for simplicity. If expand (x-1)^3 then I get
(x-1)^3 = x^3-3*x^3+3*x-1;
which includes all powers of x from 0 to 3, as we know. Now, I need to substitute x with e(1), x^2 with e(2), x^3 with e(3).
Unfortunately, I cannot use 'subs' command here since when I try to assign x with e(1), it automatically assigns x^2 with
e(1)^2 and x^3 with e(1)^3 which is not what I want (similarly, if I try to asign x^2 with e(2) it might interfere with other powers
of x).
Ant idea?
Thanks!
Babak
2 个评论
Rik
2022-1-26
If by e(k) you mean exp(k), isn't the replacement equivalent to what you want? It might not look tidy, but it is the same number.
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Number Theory 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!