From: Loris Barton on
Do you know if there is a manner or a function that allow me to create a variable with the content of a cell (string), for example if I have the cell P='0.5x(1)+x(2)' ; I want to create the variable A=0.5x(1)+x(2)
From: us on
"Loris Barton" <loris819(a)msn.com> wrote in message <hl1och$320$1(a)fred.mathworks.com>...
> Do you know if there is a manner or a function that allow me to create a variable with the content of a cell (string), for example if I have the cell P='0.5x(1)+x(2)' ; I want to create the variable A=0.5x(1)+x(2)

one of the solutions
- if(f) i understand you correctly...

c={'0.5*x(1)+x(2)'}; % <- note: correction of typo...
fun=str2func(['@(x)',c{1}]);
x=[1,10];
fun(x)
% ans = 10.5

us