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
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
"Snow White" <gulesaman@gmail.com> wrote in message
news: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.
That's correct. If any of A, B, or C are empty then ISNAN or ISINF on those
varaibles will not return a logical scalar value, but will return a logical
empty value.
By the way, you can use ~ISFINITE() on each variable to replace one call to
ISINF and one call to ISNAN.
thank you that worked so far#!
"Sadik " <sadik.hava@gmail.com> wrote in message <gveele$3nm$1@fred.mathworks.com>...
> 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
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central.
Read the complete Terms prior to use.