<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/238364</link>
    <title>MATLAB Central Newsreader - Problem with very simple script</title>
    <description>Feed for thread: Problem with very simple script</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>Wed, 29 Oct 2008 17:04:09 -0400</pubDate>
      <title>Problem with very simple script</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/238364#607924</link>
      <author>Clemens</author>
      <description>Hi&lt;br&gt;
&lt;br&gt;
I have a very simple problem. I have a 32-bit integer value and&lt;br&gt;
I wanna store each byte of this word in one chunk of 8-bits. So my idea &lt;br&gt;
was using a bitmask that extracts me each byte and then I wanna use&lt;br&gt;
bitsra to rightshift the extract byte to the LSB and use then another&lt;br&gt;
bitand to extract the final byte value. However, in the code fragement&lt;br&gt;
below I get the error message that bitsra cant be used on values from &lt;br&gt;
type 'double'. Anyone an idea how I could get around this problem?&lt;br&gt;
&lt;br&gt;
LSB   = 255;&lt;br&gt;
mask  = 255;&lt;br&gt;
value = 3545883001; %D359E179&lt;br&gt;
&lt;br&gt;
chunk(1) = bitand(value,mask);&lt;br&gt;
&lt;br&gt;
for i=2:4&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;mask     = bitshift(mask,8);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;chunk(i) = bitand(bitsra(bitand(value,mask),(i-1)*8),LSB);&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
Many thanks,&lt;br&gt;
Clemens!</description>
    </item>
    <item>
      <pubDate>Wed, 29 Oct 2008 17:22:01 -0400</pubDate>
      <title>Re: Problem with very simple script</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/238364#607928</link>
      <author>Bruno Luong</author>
      <description>Clemens &amp;lt;Clemi@hotmail.com&amp;gt; wrote in message &amp;lt;gea529$cgk$1@aioe.org&amp;gt;...&lt;br&gt;
&amp;gt; Hi&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I have a very simple problem. I have a 32-bit integer value and&lt;br&gt;
&amp;gt; I wanna store each byte of this word in one chunk of 8-bits. So my idea &lt;br&gt;
&amp;gt; was using a bitmask that extracts me each byte and then I wanna use&lt;br&gt;
&amp;gt; bitsra to rightshift the extract byte to the LSB and use then another&lt;br&gt;
&amp;gt; bitand to extract the final byte value. However, in the code fragement&lt;br&gt;
&amp;gt; below I get the error message that bitsra cant be used on values from &lt;br&gt;
&amp;gt; type 'double'. Anyone an idea how I could get around this problem?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; LSB   = 255;&lt;br&gt;
&amp;gt; mask  = 255;&lt;br&gt;
&amp;gt; value = 3545883001; %D359E179&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; chunk(1) = bitand(value,mask);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; for i=2:4&lt;br&gt;
&amp;gt;    mask     = bitshift(mask,8);&lt;br&gt;
&amp;gt;    chunk(i) = bitand(bitsra(bitand(value,mask),(i-1)*8),LSB);&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Many thanks,&lt;br&gt;
&amp;gt; Clemens!&lt;br&gt;
&lt;br&gt;
Please take a look at function  TYPECAST&lt;br&gt;
&lt;br&gt;
Bruno</description>
    </item>
    <item>
      <pubDate>Wed, 29 Oct 2008 17:59:44 -0400</pubDate>
      <title>Re: Problem with very simple script</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/238364#607932</link>
      <author>Clemens</author>
      <description>Bruno Luong wrote:&lt;br&gt;
&amp;gt; Clemens &amp;lt;Clemi@hotmail.com&amp;gt; wrote in message &amp;lt;gea529$cgk$1@aioe.org&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 have a very simple problem. I have a 32-bit integer value and&lt;br&gt;
&amp;gt;&amp;gt; I wanna store each byte of this word in one chunk of 8-bits. So my idea &lt;br&gt;
&amp;gt;&amp;gt; was using a bitmask that extracts me each byte and then I wanna use&lt;br&gt;
&amp;gt;&amp;gt; bitsra to rightshift the extract byte to the LSB and use then another&lt;br&gt;
&amp;gt;&amp;gt; bitand to extract the final byte value. However, in the code fragement&lt;br&gt;
&amp;gt;&amp;gt; below I get the error message that bitsra cant be used on values from &lt;br&gt;
&amp;gt;&amp;gt; type 'double'. Anyone an idea how I could get around this problem?&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; LSB   = 255;&lt;br&gt;
&amp;gt;&amp;gt; mask  = 255;&lt;br&gt;
&amp;gt;&amp;gt; value = 3545883001; %D359E179&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; chunk(1) = bitand(value,mask);&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; for i=2:4&lt;br&gt;
&amp;gt;&amp;gt;    mask     = bitshift(mask,8);&lt;br&gt;
&amp;gt;&amp;gt;    chunk(i) = bitand(bitsra(bitand(value,mask),(i-1)*8),LSB);&lt;br&gt;
&amp;gt;&amp;gt; end&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; Many thanks,&lt;br&gt;
&amp;gt;&amp;gt; Clemens!&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Please take a look at function  TYPECAST&lt;br&gt;
&lt;br&gt;
I will, but I just see that bitsra is not supported by matlab 2006a. Is &lt;br&gt;
there another way I can shift the values 6 bits to the RIGHT?&lt;br&gt;
&lt;br&gt;
Many thanks,&lt;br&gt;
Clemens</description>
    </item>
    <item>
      <pubDate>Wed, 29 Oct 2008 18:09:01 -0400</pubDate>
      <title>Re: Problem with very simple script</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/238364#607936</link>
      <author>Bruno Luong</author>
      <description>Clemens &amp;lt;Clemi@hotmail.com&amp;gt; wrote in message &amp;lt;gea8ag$p8r$1@aioe.org&amp;gt;...&lt;br&gt;
. Is &lt;br&gt;
&amp;gt; there another way I can shift the values 6 bits to the RIGHT?&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
floor(r/2^6)?&lt;br&gt;
&lt;br&gt;
Bruno</description>
    </item>
    <item>
      <pubDate>Wed, 29 Oct 2008 19:05:20 -0400</pubDate>
      <title>Re: Problem with very simple script</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/238364#607944</link>
      <author>Walter Roberson</author>
      <description>Clemens wrote:&lt;br&gt;
&amp;gt; I just see that bitsra is not supported by matlab 2006a. Is &lt;br&gt;
&amp;gt; there another way I can shift the values 6 bits to the RIGHT?&lt;br&gt;
&lt;br&gt;
I don't see any bitsra in R2007a.&lt;br&gt;
&lt;br&gt;
To shift bit values to the right, use bitshift with a negative shift.</description>
    </item>
  </channel>
</rss>

