MATLAB: How to use str2func to replace eval command

evalstr2func

I want user to enter a parametrized function in terms of t. Is there a way that I can have an input function instead of using '' and eval?
t = linspace(0.001,2,1000);
T = t;
x_e = 't.^3';
y_e = 'exp(t)';
z_e = 'cos(10*t)';
x = eval(x_e);
y = eval(y_e);
z = eval(z_e);

Best Answer

fx = str2func(['@(t) ', x_e]);
x = fx(t);