From: Kyle on
I cannot figure out why I keep getting this error:

??? Operands to the || and && operators must be convertible to logical scalar values.

here is part of my code:

fun=@(t)8*x*(t^2)+Growth+Length+Width
x = fzero(fun,1)

Where growth, length, and width are the result of other equations in my code. I have this code in a for loop to find the value at which this function is zero at 30 different values for a particular parameter that each equation is dependent upon. What am I doing wrong?
From: Matt Fig on
When making functions for fzero, use .* and .^ instead of * and ^.
From: Steven Lord on

"Kyle " <kyle.bm(a)hotmail.com> wrote in message
news:hork8q$ra0$1(a)fred.mathworks.com...
>I cannot figure out why I keep getting this error:
>
> ??? Operands to the || and && operators must be convertible to logical
> scalar values.
>
> here is part of my code:
>
> fun=@(t)8*x*(t^2)+Growth+Length+Width
> x = fzero(fun,1)
>
> Where growth, length, and width are the result of other equations in my
> code. I have this code in a for loop to find the value at which this
> function is zero at 30 different values for a particular parameter that
> each equation is dependent upon. What am I doing wrong?

The function that you pass into FZERO must accept a SCALAR input and return
a real SCALAR output. I suspect your function returns a nonscalar value.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


From: Kyle on
Yea, I tried that too. I thought maybe that was the issue since I'm using various loops and multiple values for a few variables but it still gives me that same error. What else do you think could cause this problem?
From: Matt Fig on
"Matt Fig" <spamanon(a)yahoo.com> wrote in message <horkq6$529$1(a)fred.mathworks.com>...
> When making functions for fzero, use .* and .^ instead of * and ^.

Scratch that. FZERO takes scalars in and scalars out. Does your function take a scalar in and return a scalar?