<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/252146</link>
    <title>MATLAB Central Newsreader - logical scalar values input</title>
    <description>Feed for thread: logical scalar values input</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Mon, 25 May 2009 15:36:01 -0400</pubDate>
      <title>logical scalar values input</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/252146#652262</link>
      <author>Snow White</author>
      <description>Hi,&lt;br&gt;
&lt;br&gt;
i wrote the following piece of code:&lt;br&gt;
&lt;br&gt;
if (isnan(A) || isnan(B) || isnan(C) || isinf(A) || isinf(B) || isinf(C))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;value_chk=1;&lt;br&gt;
else&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;r = roots(p); %%computing roots of the equation inorder to find the refractive index&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[root_size rr]=size(r);&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
now i am getting these values although A=B=C are matrices of 1 or 0&lt;br&gt;
&lt;br&gt;
??? Operands to the || and &amp;&amp; operators must be convertible to logical scalar values.&lt;br&gt;
Bye</description>
    </item>
    <item>
      <pubDate>Mon, 25 May 2009 15:49:02 -0400</pubDate>
      <title>Re: logical scalar values input</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/252146#652267</link>
      <author>Sadik </author>
      <description>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&lt;br&gt;
&lt;br&gt;
sum(A(:))&lt;br&gt;
&lt;br&gt;
so you would have&lt;br&gt;
&lt;br&gt;
isnan(sum(A(:))) || isnan(sum(B(:))) || ...&lt;br&gt;
&lt;br&gt;
and so on [since NaN + any number is NaN].&lt;br&gt;
&lt;br&gt;
&quot;Snow White&quot; &amp;lt;gulesaman@gmail.com&amp;gt; wrote in message &amp;lt;gvedt1$f1n$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; i wrote the following piece of code:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; if (isnan(A) || isnan(B) || isnan(C) || isinf(A) || isinf(B) || isinf(C))&lt;br&gt;
&amp;gt;     value_chk=1;&lt;br&gt;
&amp;gt; else&lt;br&gt;
&amp;gt;     r = roots(p); %%computing roots of the equation inorder to find the refractive index&lt;br&gt;
&amp;gt;     [root_size rr]=size(r);&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; now i am getting these values although A=B=C are matrices of 1 or 0&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ??? Operands to the || and &amp;&amp; operators must be convertible to logical scalar values.&lt;br&gt;
&amp;gt; Bye</description>
    </item>
    <item>
      <pubDate>Mon, 25 May 2009 15:59:03 -0400</pubDate>
      <title>Re: logical scalar values input</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/252146#652270</link>
      <author>Matt Fig</author>
      <description>You may want to use any(isnan(A)) etc, depending on what you are trying to do.</description>
    </item>
    <item>
      <pubDate>Mon, 25 May 2009 16:23:03 -0400</pubDate>
      <title>Re: logical scalar values input</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/252146#652275</link>
      <author>Steven Lord</author>
      <description>&lt;br&gt;
&quot;Snow White&quot; &amp;lt;gulesaman@gmail.com&amp;gt; wrote in message &lt;br&gt;
news:gvedt1$f1n$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; i wrote the following piece of code:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; if (isnan(A) || isnan(B) || isnan(C) || isinf(A) || isinf(B) || isinf(C))&lt;br&gt;
&amp;gt;    value_chk=1;&lt;br&gt;
&amp;gt; else&lt;br&gt;
&amp;gt;    r = roots(p); %%computing roots of the equation inorder to find the &lt;br&gt;
&amp;gt; refractive index&lt;br&gt;
&amp;gt;    [root_size rr]=size(r);&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; now i am getting these values although A=B=C are matrices of 1 or 0&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; ??? Operands to the || and &amp;&amp; operators must be convertible to logical &lt;br&gt;
&amp;gt; scalar values.&lt;br&gt;
&lt;br&gt;
That's correct.  If any of A, B, or C are empty then ISNAN or ISINF on those &lt;br&gt;
varaibles will not return a logical scalar value, but will return a logical &lt;br&gt;
empty value.&lt;br&gt;
&lt;br&gt;
By the way, you can use ~ISFINITE() on each variable to replace one call to &lt;br&gt;
ISINF and one call to ISNAN.&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Steve Lord&lt;br&gt;
slord@mathworks.com </description>
    </item>
    <item>
      <pubDate>Mon, 25 May 2009 16:36:01 -0400</pubDate>
      <title>Re: logical scalar values input</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/252146#652278</link>
      <author>Snow White</author>
      <description>thank you that worked so far#!&lt;br&gt;
&quot;Sadik &quot; &amp;lt;sadik.hava@gmail.com&amp;gt; wrote in message &amp;lt;gveele$3nm$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; 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&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; sum(A(:))&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; so you would have&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; isnan(sum(A(:))) || isnan(sum(B(:))) || ...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; and so on [since NaN + any number is NaN].&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &quot;Snow White&quot; &amp;lt;gulesaman@gmail.com&amp;gt; wrote in message &amp;lt;gvedt1$f1n$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Hi,&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; i wrote the following piece of code:&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; if (isnan(A) || isnan(B) || isnan(C) || isinf(A) || isinf(B) || isinf(C))&lt;br&gt;
&amp;gt; &amp;gt;     value_chk=1;&lt;br&gt;
&amp;gt; &amp;gt; else&lt;br&gt;
&amp;gt; &amp;gt;     r = roots(p); %%computing roots of the equation inorder to find the refractive index&lt;br&gt;
&amp;gt; &amp;gt;     [root_size rr]=size(r);&lt;br&gt;
&amp;gt; &amp;gt; end&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; now i am getting these values although A=B=C are matrices of 1 or 0&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; ??? Operands to the || and &amp;&amp; operators must be convertible to logical scalar values.&lt;br&gt;
&amp;gt; &amp;gt; Bye</description>
    </item>
  </channel>
</rss>

