help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: R rep equivalent in octave


From: Jordi Gutiérrez Hermoso
Subject: Re: R rep equivalent in octave
Date: Fri, 8 Jul 2011 17:45:14 -0400

On 8 July 2011 17:23, drx <address@hidden> wrote:

> x=[ 1 2 3 4 ];
> rep=[ 2 3 1 3 ];
> z=[];
> for i=1:length(x)
>   z=[ z x(i)*ones(1,rep(i))];
> end
>
> I would like to be able to write something like
> z=vectorialFunction(x,rep);
> instead of the loop.

Typing "doc rep" to see what would come up in the manual, I found
this:

     z = repelems(x,[1:4;rep])

HTH,
- Jordi G. H.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]