Simple vector question.
이전 댓글 표시
function vec = weave(in1, in2)
a = length(in1);
b = length(in2);
l = max(a,b);
vec = zeros(1, 2.*l);
vec(1:2:2.*a) = in1;
vec(2:2:2.*b) = in2;
I'm trying to create a function that a larger vector where the values in the first vector are inserted in the odd indices and the values in the second vector are inserted in the even indices(weave). The condition is that f the two vectors are not the same length, the shorter vector should be extended by adding consecutive integers to the end. I figured out how to put put those vectors into the position but I couldn't figure out how to extend shorter vector by adding consecutive integers(I could only figure out to fill that with same integers.) What would be the solution?
- For example, [5 4 1 8 9 1] [7 3 5 5] becomes [5 7 4 3 1 5 8 5 9 6 1 7] instead of [5 7 4 3 1 5 8 5 9 0 1 0].
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Call Web Services from MATLAB Using HTTP에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!