Path: news.mathworks.com!not-for-mail
From: "Sadik " <sadik.hava@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: logical scalar values input
Date: Mon, 25 May 2009 15:49:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 26
Message-ID: <gveele$3nm$1@fred.mathworks.com>
References: <gvedt1$f1n$1@fred.mathworks.com>
Reply-To: "Sadik " <sadik.hava@gmail.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1243266542 3830 172.30.248.38 (25 May 2009 15:49:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 25 May 2009 15:49:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1666517
Xref: news.mathworks.com comp.soft-sys.matlab:542407


If the input to isnan is a matrix, it will return a matrix showing the locations of NaNs by 1. What you could do instead is replacing every matrix-like inputs with

sum(A(:))

so you would have

isnan(sum(A(:))) || isnan(sum(B(:))) || ...

and so on [since NaN + any number is NaN].

"Snow White" <gulesaman@gmail.com> wrote in message <gvedt1$f1n$1@fred.mathworks.com>...
> Hi,
> 
> i wrote the following piece of code:
> 
> if (isnan(A) || isnan(B) || isnan(C) || isinf(A) || isinf(B) || isinf(C))
>     value_chk=1;
> else
>     r = roots(p); %%computing roots of the equation inorder to find the refractive index
>     [root_size rr]=size(r);
> end
> 
> now i am getting these values although A=B=C are matrices of 1 or 0
> 
> ??? Operands to the || and && operators must be convertible to logical scalar values.
> Bye