Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Generating of Data
Date: Sat, 18 Apr 2009 20:53:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 57
Message-ID: <gsdejd$fpk$1@fred.mathworks.com>
References: <gsbdrh$m6u$1@fred.mathworks.com> <gscacm$qcr$1@fred.mathworks.com> <gsd1dh$gij$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 1240087981 16180 172.30.248.35 (18 Apr 2009 20:53:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 18 Apr 2009 20:53:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:533749

"Lin " <shenqlv@yahoo.com> wrote in message <gsd1dh$gij$1@fred.mathworks.com>...
> "Lin Li" <KuvertDEL@gmailDEL.comDEL> wrote in message <gscacm$qcr$1@fred.mathworks.com>...
> 
> > It seems that the first 3 line act binary, while the last line acts in a [user_input -1] system, so if it is so:
> > 
> > in = input('input = ');
> > first3 = reshape(repmat((dec2bin(0:7) - '0')', in, 1), 3, []);
> > last = 0:in - 1;
> > last = repmat(last, 1, size(first3, 2)/size(last, 2));
> > answ = [first3; last]
> 
> Actually, there should be 2 prompting to the user.
> 
> 1) Column (defining the height of the column)
> 2) input
> 
> If Column = 2 and input = 2, I need something like
> 
> 0 0 1 1
> 0 1 0 1
> 
> if Column = 2, input = 3
> 
> 0 0 0 1 1 1 2 2 2
> 0 1 2 0 1 2 0 1 2
> 
> if Column = 2, input = 4
> 
> 0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3
> 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3
> 
> if Column = 3, input = 2
> 
> 0 0 0 0 1 1 1 1
> 0 0 1 1 0 0 1 1
> 0 1 0 1 0 1 0 1
> 
> if Column = 3, input = 3
> 
> 0 0 0 0 0 0 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 
> 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 2 2 2
> 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2
> 
> invalid when column = 1 and input = 1
> invalid when column = 5 onwards, input = 5 onwards
> 
> Sorry for the misunderstanding. Thanks for helping.

  I still say you need 'dec2base', Lin.  It would look something like:

 answ = (dec2base((0:(in^col-1)).',in,col)-'0').';

I am assuming here that for a column vector input to 'dec2base', it will output a column of strings - I don't have it on my system to try.

  Your col = 3, in = 3 example is short by six columns.

Roger Stafford