I need to write the function among others in MATLAB, but I keep getting "Array indices must be positive integers or logical values." error and an error for both functions f(x) and u(x) saying "Error in f(x(j)) = ..." or "Error in u(x(j)) = ....." Why is that?
This is the code relating to that
for j=1:n
x(j)=-1+j*h;
f(x(j)) = (pi.^2).*(exp(cos(pi.*x(j)))).*(cos(pi.*x(j))-(sin(pi.*x(j))).^2);
u(x(j))= -f(x(j));
end