For example I got a = [1 3 5], b = [2 4] and I want to get a c = [1 2 3 4 5 ]
Basically it'd insert the vaule from b between a's two elements

답변 (3개)

Bruno Luong
Bruno Luong 2020년 8월 28일

1 개 추천

a(1:2:2*end-1) = a;
a(2*(1:length(b))) = b
Osip Vayner
Osip Vayner 2020년 8월 28일

0 개 추천

KSSV's code is correct.
And just in case you want to combine two vectors vertically:
d = sort([a;b])

카테고리

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

제품

질문:

2020년 4월 20일

답변:

2020년 8월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by