Hello everyone. I have a question.
I have an array which has 500 elements such as A = [1,2,3,4,5,6,7...500]
And I want to copy last values of the each dual arrays and add them after dual arrays like that --> B = [1,2,2,3,4,4,5,6,6,7,8,8,.....,500]
How can I do this?
Thanks..

 Akzeptierte Antwort

madhan ravi
madhan ravi am 13 Feb. 2019
Bearbeitet: madhan ravi am 13 Feb. 2019

2 Stimmen

A=1:500;
B=zeros(1,numel(A)+floor(numel(A)/2));
B(3:3:end)=A(2:2:end);
B(setdiff(1:numel(B),3:3:end))=A

2 Kommentare

OKG
OKG am 13 Feb. 2019
great! Thank you!
KALYAN ACHARJYA
KALYAN ACHARJYA am 13 Feb. 2019
+1 Great

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Community Treasure Hunt

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

Start Hunting!

Translated by