Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to NOT get the first element as the max when elements are equal
Date: Fri, 11 May 2012 05:35:25 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 12
Message-ID: <joi8et$g99$1@newscl01ah.mathworks.com>
References: <johivn$ni4$1@newscl01ah.mathworks.com> <johr01$o50$1@newscl01ah.mathworks.com> <joi6n4$9oa$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1336714525 16681 172.30.248.47 (11 May 2012 05:35:25 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 11 May 2012 05:35:25 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:767466

"Yildiray Yildiz" wrote in message <joi6n4$9oa$1@newscl01ah.mathworks.com>...
> Excellent! Thank you, Roger. One note: For some reason t(f) = rand(length(f),1) did not work.
> I had to do:
> 
> t = t*rand;
> t(f) = rand(length(f),1);
> 
> Although I do not know why I had to modify the "t" matrix first, it worked.
- - - - - - - - -
  The "t(f) = rand(length(f),1);" line works on my matlab version without modifying t first, but it is a very old version.  Probably the "t = t*rand;" simply serves to convert 't' from a logical array to a numerical one with 1's and 0's.  If so, you can probably just do "t = t+0" or "t = double(t)" instead.

Roger Stafford