Path: news.mathworks.com!newsfeed-00.mathworks.com!kanaga.switch.ch!switch.ch!newsfeed00.sul.t-online.de!t-online.de!news.k-dsl.de!aioe.org!not-for-mail
From: Clemens <Clemi@hotmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Problem with very simple script
Date: Wed, 29 Oct 2008 17:59:44 +0000
Organization: Aioe.org NNTP Server
Lines: 33
Message-ID: <gea8ag$p8r$1@aioe.org>
References: <gea529$cgk$1@aioe.org> <gea63p$lqu$1@fred.mathworks.com>
Reply-To: Clemi@hotmail.com
NNTP-Posting-Host: iwazocMqq37NFvTzXicAGg.user.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@aioe.org
NNTP-Posting-Date: Wed, 29 Oct 2008 17:59:45 +0000 (UTC)
X-Notice: Filtered by postfilter v. 0.7.4
User-Agent: Thunderbird 1.5.0.12 (X11/20070529)
Xref: news.mathworks.com comp.soft-sys.matlab:497853


Bruno Luong wrote:
> Clemens <Clemi@hotmail.com> wrote in message <gea529$cgk$1@aioe.org>...
>> Hi
>>
>> I have a very simple problem. I have a 32-bit integer value and
>> I wanna store each byte of this word in one chunk of 8-bits. So my idea 
>> was using a bitmask that extracts me each byte and then I wanna use
>> bitsra to rightshift the extract byte to the LSB and use then another
>> bitand to extract the final byte value. However, in the code fragement
>> below I get the error message that bitsra cant be used on values from 
>> type 'double'. Anyone an idea how I could get around this problem?
>>
>> LSB   = 255;
>> mask  = 255;
>> value = 3545883001; %D359E179
>>
>> chunk(1) = bitand(value,mask);
>>
>> for i=2:4
>>    mask     = bitshift(mask,8);
>>    chunk(i) = bitand(bitsra(bitand(value,mask),(i-1)*8),LSB);
>> end
>>
>> Many thanks,
>> Clemens!
> 
> Please take a look at function  TYPECAST

I will, but I just see that bitsra is not supported by matlab 2006a. Is 
there another way I can shift the values 6 bits to the RIGHT?

Many thanks,
Clemens