I have been exploring the Matlab symbolic toolbox, in preparation for an upcoming final. However, I seem not to be able to convert a string inputted from the user to a symbolic expression, and then use it for integration.
a = input('Plese enter a = ');
b = input('Please enter b = ');
function1 = input('Please enter the function: ', 's');
syms x eq1
eq1 = sym(function1);
Integral1 = int(eq1 , x, a, b);
Simpson = 1 / 6 * (b - a) * (subs(eq1 , x, a) + 4 * ...
(subs(eq1 , x, (a+b)/2))...
+ subs(eq1 , x, b));
fprintf('The value of the integral is %s \n', Integral1);
fprtinf('The aprroximation with simp is %s \n', Simpson);
Simpson is the integral approximation from simpson's rule. The error I get is something along the lines of "Conversion to 'sym' returned the MuPAD error: Error: unexpected 'identifier'" the line number would be the line
eq1 = sym(function1);