Mostrar comentarios más antiguos
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?
Respuesta aceptada
Más respuestas (2)
Patrick Kalita
el 21 de Oct. de 2011
I think feval would be a better option here. It is a safer than eval, and it easily accommodates passing input arguments:
feval( whatplot, plots )
3 comentarios
Fangjun Jiang
el 21 de Oct. de 2011
Yes. feval() is the way to go. I was thinking about inline(), @, etc.
Jan
el 21 de Oct. de 2011
@Tor: Avoid EVAL. As you see, it causes troubles.
Tor Fredrik Hove
el 21 de Oct. de 2011
Wayne King
el 21 de Oct. de 2011
plots=[3 4 6 1];
whatplot = 'bar';
eval([whatplot '(plots)'])
1 comentario
Wayne King
el 21 de Oct. de 2011
also, see the comments by other posters above.
Categorías
Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!