Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Generating of Data
Date: Sun, 19 Apr 2009 11:11:02 +0000 (UTC)
Organization: IAV GmbH
Lines: 20
Message-ID: <gsf0s6$g2r$1@fred.mathworks.com>
References: <gsbdrh$m6u$1@fred.mathworks.com> <gscacm$qcr$1@fred.mathworks.com> <gsd1dh$gij$1@fred.mathworks.com> <gsdejd$fpk$1@fred.mathworks.com> <gsdmb0$rmb$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1240139462 16475 172.30.248.38 (19 Apr 2009 11:11:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 19 Apr 2009 11:11:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1745926
Xref: news.mathworks.com comp.soft-sys.matlab:533817

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gsdmb0$rmb$1@fred.mathworks.com>...
> "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gsdejd$fpk$1@fred.mathworks.com>...
> > .....
> >  answ = (dec2base((0:(in^col-1)).',in,col)-'0').';
> > .....
> 
>   Here's an alternative method which avoids generating strings:
> 
>  % Let b = input (base) and n = no. of columns
>  answ = mod(floor(((1/b).^(0:n-1).'/2)*(1:2:2*b^n)),b);
> 
> I have no idea whether it is faster, but it should at least be interesting to see why it works.
> 
> Roger Stafford

Very interesting use of the mod and floor, great idea!
A last line should be added:
answ = flipud(answ);

Lin Li