Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
how to stop the logical errors

Subject: how to stop the logical errors

From: Vinz A

Date: 4 Aug, 2010 21:08:04

Message: 1 of 4

Hi all,

Can somebody please please to solve the below error.
Iam not using any logical opertors in my program, but still this error pops up when I open the matlab and it for first; when I run for the 2nd time, it gives me correct results. I really have no clue why this error messages comes up for the first time.
I have also check my values none of them is a neagative values.

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

Error in ==> fzero at 333
    elseif ~isfinite(fx) || ~isreal(fx)

Error in ==> BRALHX_Condenser_Equations at 74
       Fdel=fzero(Fun,1.4766e-007,options);

Error in ==> odearguments at 110
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.

Error in ==> ode15s at 228
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...

Is there a way to know what exactly, the error mean??/
My program is too long to post it.

Cheers
VJ

Subject: how to stop the logical errors

From: us

Date: 4 Aug, 2010 21:16:04

Message: 2 of 4

"Vinz A" <vinzav@gmail.com> wrote in message <i3ckrk$1m0$1@fred.mathworks.com>...
> Hi all,
>
> Can somebody please please to solve the below error.
> Iam not using any logical opertors in my program, but still this error pops up when I open the matlab and it for first; when I run for the 2nd time, it gives me correct results. I really have no clue why this error messages comes up for the first time.
> I have also check my values none of them is a neagative values.
>
> ?? Operands to the || and && operators must be convertible to logical scalar values.
>
> Error in ==> fzero at 333
> elseif ~isfinite(fx) || ~isreal(fx)
>
> Error in ==> BRALHX_Condenser_Equations at 74
> Fdel=fzero(Fun,1.4766e-007,options);
>
> Error in ==> odearguments at 110
> f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
>
> Error in ==> ode15s at 228
> [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
>
> Is there a way to know what exactly, the error mean??/
> My program is too long to post it.
>
> Cheers
> VJ

how can CSSMers possibly be of any help with this quickly spewed collection of error messages(?)...
try to provide the most parsimonious snippet of ML code, which reproduces this error...

us

Subject: how to stop the logical errors

From: Jan Simon

Date: 4 Aug, 2010 22:27:04

Message: 3 of 4

Dear Vinz,

> Can somebody please please to solve the below error.

The debugger can. A newsgroup can't.

> ?? Operands to the || and && operators must be convertible to logical scalar values.
> Error in ==> fzero at 333
> elseif ~isfinite(fx) || ~isreal(fx)
> Is there a way to know what exactly, the error mean??/

The message means, that fx is not a scalar.
Now let the debugger stop in the failing line and inspect, why fx is not a scalar:
  dbstop if error

Good luck, Jan

Subject: how to stop the logical errors

From: Steven_Lord

Date: 5 Aug, 2010 13:58:12

Message: 4 of 4



"Vinz A" <vinzav@gmail.com> wrote in message
news:i3ckrk$1m0$1@fred.mathworks.com...
> Hi all,
>
> Can somebody please please to solve the below error.
> Iam not using any logical opertors in my program, but still this error
> pops up when I open the matlab and it for first; when I run for the 2nd
> time, it gives me correct results. I really have no clue why this error
> messages comes up for the first time.
> I have also check my values none of them is a neagative values.
>
> ?? Operands to the || and && operators must be convertible to logical
> scalar values.
>
> Error in ==> fzero at 333
> elseif ~isfinite(fx) || ~isreal(fx)
>
> Error in ==> BRALHX_Condenser_Equations at 74
> Fdel=fzero(Fun,1.4766e-007,options);

What requirements does FZERO have for the objective function you pass into
it as the first input argument?

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/fzero.html

"fun is the function whose zero is to be computed. It accepts a vector x and
returns a scalar f, the objective function evaluated at x."

The most important word in that quote is SCALAR. If your function returns a
NON-scalar value, you will receive this error.

If you're trying to solve a system of equations, rather than one equation,
you will need to use FSOLVE from Optimization Toolbox instead of FZERO.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us