フィルターのクリア

repeat in the same vector

2 ビュー (過去 30 日間)
Marco Carapellese
Marco Carapellese 2022 年 3 月 3 日
コメント済み: Marco Carapellese 2022 年 3 月 3 日
hi to all I have a vector [1 2 3; 4 5 6] I would like to repeat the elements within another vector n times. For example, if n = 2 I would like to obtain [1 2 3 1 2 3; 4 5 6 4 5 6]. How can I do? Thank you
specifically I have this vector ripetuta(f,:, v) which I would like to construct as the vector newgreentime (:,:, v) to be repeated on lines as many times as repetizioni(f, 1, v) = floor (T / sommetime (f, end, v)) ;. The values ​​for each row of repetitions are different from each other. It's possible to do it?
for i = 1:duration
traci.simulation.step();
for n = 1: length(inductionID)
veicoliOGNIISTANTEsuInduction(n,i)=traci.inductionloop.getLastStepVehicleNumber(inductionID{n});
end
for v=1:length(k)
if i==t(v)
for n = 1: length(inductionID)
veicoliT(n,v)=sum(veicoliOGNIISTANTEsuInduction(n,(t(v)-(T-1)):t(v)));
end
for f=1:length(semaforiID)
% here begins the part of interest
newgreentime(:,:,v)=reshape(-L*veicoliT(:,v), 2,2)';
ripetizioni(f,1,v)=floor(T/sommetime(f,end,v)); % T is 90
ripetuta(:,:,v)= % i tried with a solution like ma non funziona repmat(newgreentime(f,:,v),1,ripetizioni(f,1,v));
end
end
end
end

回答 (1 件)

KSSV
KSSV 2022 年 3 月 3 日
v = [1 2 3; 4 5 6] ;
iwant = repmat(v,1,2)
iwant = 2×6
1 2 3 1 2 3 4 5 6 4 5 6
  1 件のコメント
Marco Carapellese
Marco Carapellese 2022 年 3 月 3 日
thanks for the answer, but I have modified the question to add further problems, as that mode is not usable in my case

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by