Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!l12g2000yqo.googlegroups.com!not-for-mail
From: Deivy <deivy71@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Generating Random numbers
Date: Thu, 2 Jul 2009 06:37:32 -0700 (PDT)
Organization: http://groups.google.com
Lines: 91
Message-ID: <9b29f0e3-9e7c-4922-9ae1-a8d9ce58ca38@l12g2000yqo.googlegroups.com>
References: <d639c2c7-c672-4177-b89b-5c584755dabc@x5g2000yqk.googlegroups.com> 
	<8f91f9c6-aacc-4e38-92d7-1608eeb61076@a7g2000yqk.googlegroups.com> 
	<h2id09$sbh$1@fred.mathworks.com>
NNTP-Posting-Host: 130.238.8.198
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1246541852 26680 127.0.0.1 (2 Jul 2009 13:37:32 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 2 Jul 2009 13:37:32 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: l12g2000yqo.googlegroups.com; posting-host=130.238.8.198; 
	posting-account=twjtNAoAAAD5eFO488SppmbV-BtF0_IO
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_7; en-us) 
	AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Safari/530.17,gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:552381


Hi Sadik,
Thank you very much.

I am still tring and the code works fine but for different numbers and
ranges I have to tweak I guess.
Anyway, Thanks a lot for all the help.


Thank you,
Regards,
Deivy



On Jul 2, 3:34 pm, "Sadik " <sadik.h...@gmail.com> wrote:
> B = A(indicesOf4000,:);
>
> should give you the matrix.
>
> In order to write to the text file, you need to do the following:
>
> fid = fopen('C:\4000.txt','w');
> fprintf(fid,'%d %d %d %d %d %d %d \n',A(indicesOf4000,:));
> fclose(fid);
>
> You could open the file using wordpad and you will hopefully see the numbers in a regular manner.
>
> Hope this helps.
>
>
>
> Deivy <deiv...@gmail.com> wrote in message <8f91f9c6-aacc-4e38-92d7-1608eeb61...@a7g2000yqk.googlegroups.com>...
> > Hi Sadik & John,
> > Thank you for your replies.
>
> > Sadik,
> > when such a solution exists how do I extract to another matrix or wite
> > to a text file.
>
> > Thank you,
> > Regards,
> > Deivy
>
> > On Jul 2, 2:45?pm, "John D'Errico" <woodch...@rochester.rr.com> wrote:
> > > Deivy <deiv...@gmail.com> wrote in message <1602c78c-e855-4e3b-a483-4fa3ecba6...@h8g2000yqm.googlegroups.com>...
>
> > > > Hi Sadik,
> > > > Thanks for the reply.
> > > > The choice of 3000 was accidental and it made the case bit easier.
>
> > > > What if the total is 4000, where it is not directly related to any of
> > > > the numbers 500 and 600, and how do I do that.
>
> > > You should recognize that this is not possible in some
> > > circumstances, and certainly will not be a random set
> > > of numbers.
>
> > > For example, write the number 2401 as the sum of ANY
> > > size set of numbers in the range [500,600]. It cannot
> > > be done.
>
> > > Or, write 2500 as such a sum? It turns out there is only
> > > one such solution, 2500 = 500 + 500 + 500 + 500 + 500.
> > > You may not think of this solution as a random set.
>
> > > Regardless, even if a solution exists that is not unique,
> > > it is not random in the common sense of the word, since
> > > given the first n-1 members of the set, the last member
> > > is uniquely determined to meet the sum criterion.
>
> > > If you still insist on finding a random looking set of
> > > numbers that satisfy your sum constraint, use a simple
> > > logic:
>
> > > How many terms will the sum be composed of?
>
> > > 7*500 = 3500, and 8*500 = 4000.
> > > 7*600 = 4200
>
> > > Therefore, the sum must be composed of 7 numbers in
> > > that range.
>
> > > ?x = 500 + 100*rand(1,7);
> > > ?x = x * 4000/sum(x);
>
> > > John