%--------------------------------------------------- % Simple example script showing a use for the Matlab % function eval(). %--------------------------------------------------- funs = char('ceil', 'floor', 'fix', 'round'); x = 3.418; k = 3; f = deblank(funs(k,:)); current_fun = deblank(funs(k,:)); disp(['Evaluating ' current_fun]); str = [current_fun '(x)']; funresult = eval(str); disp(['Type of variable funresult is ' class(funresult)]); f = deblank(funs(k,:)); disp(['Evaluating ' current_fun ' using evalc instead']); str = [current_fun '(x)']; fc = evalc(str); disp(['Type of variable fc is ' class(fc)]);