Using eval undefined function or variable
20 views (last 30 days)
Rostistlav Stoyanov on 7 Jan 2018
So I have a exercise to solve a differential equation and I have to use Pikar's method to draw some of the approximations.However I have trouble using eval. Here is my code:
axis([xmin xmax -1,5]);
function z = ff(x,y)
% Calculating the approximations
And the errors I am getting are :
Error using evalin
Undefined function or variable 'x'.
Error in sym/eval (line 11)
s = evalin('caller',vectorize(map2mat(char(x))));
Error in ex1 (line 12)
Walter Roberson on 7 Jan 2018
Do not eval() a symbolic expression. Symbolic expressions are in a language that is not MATLAB and is not MUPAD.
The result of the dsolve is the symbolic expression
(4*exp(-(3*cos(15))/8)*exp((3*cos(4*x^2 - 1))/8))/3 + 2/3
When you try to eval() that, you need to have a variable named x defined, but you do not.
sol = double( subs(y, sym('x'), t) );