<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/249120</link>
    <title>MATLAB Central Newsreader - Binary array from MATLAB to simulink</title>
    <description>Feed for thread: Binary array from MATLAB to simulink</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, 15 Apr 2009 16:05:04 -0400</pubDate>
      <title>Binary array from MATLAB to simulink</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/249120#642934</link>
      <author>Sohaib Mansoor</author>
      <description>Note: I am using MATLAB r2008a&lt;br&gt;
&lt;br&gt;
I am working on a project on Adaptive Video Coding for wireless channels. &lt;br&gt;
So far I have an encoded bitstream similar to the one below (but more than 800,000 bits long):&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt;bitstr =&lt;br&gt;
&lt;br&gt;
11010100000101000100000000010101000000010100010001001&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&lt;br&gt;
Now I am trying to modulate it in Simulink using QPSK and import the result back into MATLAB. The problem I am facing is importing 'bitstr' into simulink, I have tried to use the 'From Workspace' block (simin) but it gives the following error:&lt;br&gt;
&lt;br&gt;
&quot;Invalid matrix-format variable specified as workspace input in 'untitled/From Workspace'. The matrix must have two dimensions and at least to columns.......&quot;&lt;br&gt;
&lt;br&gt;
How can I fix this error, is there any other way to import the bitstr into simulink? I am not very good in simulink, so I need a good explanation to understand how it works.&lt;br&gt;
&lt;br&gt;
Thanks</description>
    </item>
    <item>
      <pubDate>Wed, 15 Apr 2009 16:48:01 -0400</pubDate>
      <title>Re: Binary array from MATLAB to simulink</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/249120#642941</link>
      <author>Sohaib Mansoor</author>
      <description>Here's another related question:&lt;br&gt;
Why is bitstr like this:&lt;br&gt;
bitstr=[1010100101010101001111000]&lt;br&gt;
instead of this:&lt;br&gt;
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]&lt;br&gt;
&lt;br&gt;
is it because I use dec2bin to get the bit stream.</description>
    </item>
    <item>
      <pubDate>Wed, 15 Apr 2009 18:40:13 -0400</pubDate>
      <title>Re: Binary array from MATLAB to simulink</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/249120#642971</link>
      <author>Amit Kansal</author>
      <description>Hi Sohaib,&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Yes, since you are using dec2bin the output is a string of bits which is &lt;br&gt;
not usable by the From Workspace block.&lt;br&gt;
The block only works with decimals/doubles.&lt;br&gt;
&lt;br&gt;
Try using de2bi if you have the comms toolbox also or a element by element &lt;br&gt;
conversion on the string using str2num.&lt;br&gt;
&lt;br&gt;
As an example,&lt;br&gt;
&amp;gt;&amp;gt;bits = de2bi(200, 'left-msb')&lt;br&gt;
and now use &quot;bits&quot; as the variable in the From workspace block.&lt;br&gt;
&lt;br&gt;
or&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt;bitstr = dec2bin(200);&lt;br&gt;
&amp;gt;&amp;gt;for i=1:length(bitstr)&lt;br&gt;
&amp;gt;&amp;gt;    bits2(i) = str2num(bitstr(i));&lt;br&gt;
&amp;gt;&amp;gt;end&lt;br&gt;
and now use &quot;bits2&quot; as the variable in the From workspace block.&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt;isequal(bits, bits2)&lt;br&gt;
&lt;br&gt;
hth,&lt;br&gt;
Amit&lt;br&gt;
&lt;br&gt;
&quot;Sohaib Mansoor&quot; &amp;lt;contact.sohaib@gmail.com&amp;gt; wrote in message &lt;br&gt;
news:gs5341$3r5$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; Here's another related question:&lt;br&gt;
&amp;gt; Why is bitstr like this:&lt;br&gt;
&amp;gt; bitstr=[1010100101010101001111000]&lt;br&gt;
&amp;gt; instead of this:&lt;br&gt;
&amp;gt; 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]&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; is it because I use dec2bin to get the bit stream. </description>
    </item>
    <item>
      <pubDate>Thu, 16 Apr 2009 05:48:01 -0400</pubDate>
      <title>Re: Binary array from MATLAB to simulink</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/249120#643060</link>
      <author>Sohaib Mansoor</author>
      <description>Thanks Amit;&lt;br&gt;
&lt;br&gt;
the for loop is working well, but I have one little problem. Its taking too much time because the size of the string is more than 800,000 bits. Is there any way the same operation can be done but without the loops, to save time?&lt;br&gt;
&lt;br&gt;
Sohaib </description>
    </item>
  </channel>
</rss>

