[Top][All Lists]

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

R rep equivalent in octave

From: drx
Subject: R rep equivalent in octave
Date: Fri, 8 Jul 2011 14:23:03 -0700 (PDT)

   I am looking for a command equivalent to rep in R. That function return
the items repeated a specified number of time. Here is a loop that would do
the job, but I am looking for an effective vectorial way to do it, or a
native command.

x=[ 1 2 3 4 ];
rep=[ 2 3 1 3 ];
for i=1:length(x)
   z=[ z x(i)*ones(1,rep(i))];

I would like to be able to write something like
instead of the loop.

Best regards,

View this message in context:
Sent from the Octave - General mailing list archive at

reply via email to

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