MATLAB: Use of eval

eval

I am trying to use evalfunction but are having a hard time:
>> plots=[3 4 6 1]
plots =
3 4 6 1
>> whatplot=input('type type of graph: ','s')
type type of graph: bar
whatplot =
bar
>> eval(whatplot(plots))
??? Index exceeds matrix dimensions.
>>
why wont it evaluate it to a graph with bars?

Best Answer

Your call to input() returns the string bar in whatplot
but whatplot(plots) is not a string.
eval([whatplot '(plots)'])