Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



Vectorizing the "fzero" function
Posted:
Oct 31, 2010 2:23 PM


Hello,
I am trying to vectorize Matlab's "fzero" function. This is best explained by an example:
From the code below, I am expecting the output: x = [1 2]. Instead, I am returned the error shown below.
My code is: function fzero_test clear all; function g = myfun(x, a) g = x.^2  a; end
a = [1 4];
x = fzero(@(x) myfun(x,a), [0 10]) end
The returned error is: ??? Operands to the  and && operators must be convertible to logical scalar values.
Error in ==> fzero at 449 while fb ~= 0 && a ~= b
Error in ==> fzero_test at 10 x = fzero(@(x) myfun(x,a), [0 10])
Any help is greatly appreciated! Thanks!



