syms f(x) a(x)f(x)=(cos(x)-(2*x)+3);a(x)=(1/2)*(cos(x)+3);da=diff(a,x);b=pi/2.5; s='a f(x)'; disp(s); for i=(1:100) if abs(vpa(da(b)))<1 if vpa(f(a(b)))~=0 a(b)= vpa(a(b)) f(b)=vpa(f(b)) A=[num2str(a(b)),' ',num2str(f(b))]; disp(A); a(b)=vpa(a(a(b))); i=i+1; elseif vpa(f(b))==0; a(b)= vpa(a(b)) f(b)=vpa(f(b)) A=[num2str(a(b)),' ',num2str(f(b))]; disp(A); end else a(b)=vpa(a(a(b))); i=i+1; end enda f(x)Error using sym/subsasgn (line 837)Invalid indexing or function definition. When defining a function, ensure thatthe arguments are symbolic variables and the body of the function is a SYMexpression. When indexing, the input must be numeric, logical, or ':'.
MATLAB gave the error at the bottom for the code above it. Where am i doing wrong? Anyone help?
Best Answer