Path: news.mathworks.com!not-for-mail
From: "Amit Kansal" <akansal@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Binary array from MATLAB to simulink
Date: Wed, 15 Apr 2009 14:40:13 -0400
Organization: The MathWorks, Inc.
Lines: 37
Message-ID: <gs59mf$df5$1@fred.mathworks.com>
References: <gs50jg$c6e$1@fred.mathworks.com> <gs5341$3r5$1@fred.mathworks.com>
Reply-To: "Amit Kansal" <akansal@mathworks.com>
NNTP-Posting-Host: kansala.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1239820815 13797 144.212.110.88 (15 Apr 2009 18:40:15 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 15 Apr 2009 18:40:15 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
Xref: news.mathworks.com comp.soft-sys.matlab:533007


Hi Sohaib,

    Yes, since you are using dec2bin the output is a string of bits which is 
not usable by the From Workspace block.
The block only works with decimals/doubles.

Try using de2bi if you have the comms toolbox also or a element by element 
conversion on the string using str2num.

As an example,
>>bits = de2bi(200, 'left-msb')
and now use "bits" as the variable in the From workspace block.

or

>>bitstr = dec2bin(200);
>>for i=1:length(bitstr)
>>    bits2(i) = str2num(bitstr(i));
>>end
and now use "bits2" as the variable in the From workspace block.

>>isequal(bits, bits2)

hth,
Amit

"Sohaib Mansoor" <contact.sohaib@gmail.com> wrote in message 
news:gs5341$3r5$1@fred.mathworks.com...
> Here's another related question:
> Why is bitstr like this:
> bitstr=[1010100101010101001111000]
> instead of this:
> bitstr=[1 0 1 0 1 0 0 1 0 1 0  1 0 1 0 1 0 0 1 1 1 1 0 0 0]
>
> is it because I use dec2bin to get the bit stream.