MATLAB: Fix Error: Operands to the || and && operators must be convertible to logical scalar values.

fzero

Hi, here is my code:
x = zeros(1,101); x(1,1) = pi/4;
for k = 1:100 x(:,k+1) = fzero(@(y)(y-(5*sin(y))-x(1:k)),3); end a = x(1,end)
The error i am getting is :
Operands to the and && operators must be convertible to logical scalar values.
Error in fzero (line 327) elseif ~isfinite(fx) ~isreal(fx)
Error in TEST (line 13) x(:,k+1) = fzero(@(y)(y-(5*sin(y))-x(1:k)),3);
Can anyone help me with this! Thanks a lot!

Best Answer

I ma not certain what you want to do.
Try this:
x = zeros(1,101);
x(1) = pi/4;
for k = 1:100
x(:,k+1) = fzero(@(y)(y-(5*sin(y))-x(k)),3);
end
a = x(1,end)
Related Question