help-octave
[Top][All Lists]
Advanced

[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)

Hi,
   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 ];
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.

Best regards,

--
View this message in context: 
http://octave.1599824.n4.nabble.com/R-rep-equivalent-in-octave-tp3655166p3655166.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

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