Re: help
- To: mathgroup@smc.vnet.net
- Subject: [mg11687] Re: help
- From: Allan Hayes <hay@haystack.demon.co.uk>
- Date: Sat, 21 Mar 1998 18:35:21 -0500
- References: <6esofp$67g@smc.vnet.net>
tie@cscn.com wrote: > > how can i do the following with mathematica: > > 1. let X be a vector of N nonnegative numbers. > let Y be any og length N. > form the vector comprised of Y replicated according to the > corresponding > value of the element of X. > > 2. write a function seq[a,b,n] which returns n equally-spaced numbers on > the > interval [a,b]. > > thanks. > > tie@cscn.com X = {0,1,2}; Y={2,3,0}; Flatten[MapThread[Table[#,{#2}]&,{X,Y}]] {0,0,1,1,1} seq[a_,b_,c_]:= Range[a,b,(b-a)/(c-1)] seq[1.2, 6.5,4] {1.2,2.96667,4.73333,6.5} -- Allan Hayes Training and Consulting Leicester, UK hay@haystack.demon.co.uk http://www.haystack.demon.co.uk voice: +44 (0)116 271 4198 fax: +44 (0)116 271 8642