Problem about replacing syms with some other string
Show older comments
Here's my problem about replacing syms with some other string
Firstly, I create the followings,
va_d_cu = {'a','b'};
va_d_ba1 = {'a(-1)','b(-1)'};
va_d_fu1 = {'a(+1)','b(+1)'};
va_d = [va_d_cu va_d_ba1 va_d_fu1];
Then, I do the followings,
sgu_cu = [a_cu b_cu];
sgu_ba1 = [a_ba1 b_ba1];
sgu_fu1 = [a_fu1 b_fu1];
va_sgu = [sgu_cu sgu_ba1 sgu_fu1];
Finally, I run the following commands
f = a_cu + b_ba1 + b_fu1;
ff = subs(f, va_sgu, va_d)
and 'intend' to get the following,
ff = a + b(-1) + b(+1)
However, it only gives
ff = a + b(-1) + b(1);
I know that '+' cannot be used to replace something by using 'subs'. When I tried to run,
syms c
d = c;
d = subs(d,c,'f(+1)');
It gives,
d = f(1)
and when I run this,
s yms c d = c; d = subs(d,c,'+');
error message is prompted.
In order to get 'ff = a + b(-1) + b(+1), instead of using 'find and replace' technique, what commands I should use to do so?
Answers (0)
Categories
Find more on Operations on Strings 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!