I need a code to use it in m.file. It is about to ask a function from user and save it.
What I did was so but the answer was :" ans = sin(x)"
k.name = input('Enter the function')
fcn = @(x) k.name;
fcn(2)
when I run it and give it sin(x) the answer is "ans = sin(x)". What is the problem?
In fact the function I need is a function of two variables.
Another question:
I want to declare dy=cos(x)+sin(x)y when y if a function of x. Then I want matlab to calculate d2y like this:
d2y=-sin(x)+cos(x)*y+(cos(x)+sin(xy))*sin(x)
How can I do it?