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..

 채택된 답변

madhan ravi
madhan ravi 2019년 2월 13일
편집: madhan ravi 2019년 2월 13일

2 개 추천

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

OKG
OKG 2019년 2월 13일
great! Thank you!
KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 2월 13일
+1 Great

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Cell Arrays에 대해 자세히 알아보기

질문:

OKG
2019년 2월 13일

댓글:

2019년 2월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by