Changing variable names within a loop in MATLAB -


what doing wrong here (matlab)?

i want obtain lines ones below:

syms b d m l expr11 = -m-b*l*(b-m-d); jqdfe11 = simplify(expr11); 

with following loop:

for k=1:8 lhs=['jqdfe1',num2str(k)]; rhs=['expr1',num2str(k)]; eval('lhs = simplify(rhs)'); end 

but getting error:

error using eval: undefined function 'simplify' input arguments of type 'char' 

if want working. both lhs , rhs strings whereas in code, interpreted variables. want:

eval([lhs ' = simplify(' rhs ')']); 

lhs , rhs names variables stored strings, , want use actual strings when building string eval. btw, don't know why doing you're doing, consider not using eval. it's bad practice. see post loren shure mathworks on why shouldn't use it: http://blogs.mathworks.com/loren/2005/12/28/evading-eval/


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -