Function Handle-user input

jeudi 31 juillet 2014

Hi,



My question is in relation to Matlab.



I'm curious, is there anyway to employ user inputs for function handles?



By this I mean that the user is prompted to enter they're chosen function and the next line of code employs that into a handle.



My quick and rough attempt was:



a=input('enter a function in terms of x: ')

f=@(x) a



But I receive an error saying "Undefined function or variable x"



Any suggestions greatly appreciated.





0 commentaires:

Enregistrer un commentaire