Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Generating of Data
Date: Sat, 18 Apr 2009 04:44:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 35
Message-ID: <gsblqh$ef8$1@fred.mathworks.com>
References: <gsbdrh$m6u$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1240029841 14824 172.30.248.35 (18 Apr 2009 04:44:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 18 Apr 2009 04:44:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:533653

"Lin " <shenqlv@yahoo.com> wrote in message <gsbdrh$m6u$1@fred.mathworks.com>...
> Hi all
> 
> if my input is 2; 
> i need something like:
> 
> 0 0 0 ..... 1
> 0 1 1 ......1
> 0 0 1 ......1
> 
> and this can be generated using:
> dec2bin(0:7)'-'0';
> 
> however, when i change my input; the earlier code is no longer valid. Is there a better way of doing? Some expected results are shown below.
> 
> %Expected Results
> input = 3 
> i need something as follows:
> 
> 0 0 0 0 0 0 1 1 1 1 1 1 
> 0 0 0 1 1 1 0 0 0 1 1 1 
> 0 1 2 0 1 2 0 1 2 0 1 2
> 
> when input is 4; it should look something like:
> 
> 0 0 0 0 0 0 0 0 0 .................... 1 1 1
> 0 0 0 0 0 0 0 0 1 .................... 1 1 1
> 0 0 0 0 1 1 1 1 0 .................... 1 1 1
> 0 1 2 3 0 1 2 3 0 .................... 1 2 3
> 
> Thanks in advance for your help.

  If your "input" refers to the base of your digits, presumably you can make use of the matlab function 'dec2base'.  I don't completely understand your examples, however.

Roger Stafford