MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: help



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




  • Prev by Date: Re: Question: inequalities
  • Next by Date: RE: Plotting a Vertical Line
  • Prev by thread: Re: help
  • Next by thread: Re: help