필터 지우기
필터 지우기

Fill a vector with two vectors

조회 수: 3 (최근 30일)
Eva Maria Leal Munoz
Eva Maria Leal Munoz 2020년 11월 24일
답변: Eva Maria Leal Munoz 2020년 11월 24일
Hello, I have two vectors, Ex: V1 = [3 8 6 7 ] and V2= [1 5 9 4 ]. With V1 and V2, I would like to create the following vector: Result = [ 8 5 6 9 7 4]. How can I do this?
Thanks in advance,
Eva

채택된 답변

Stephan
Stephan 2020년 11월 24일
편집: Stephan 2020년 11월 24일
V1 = [3 8 6 7]
V2 = [1 5 9 4]
V = reshape([V1;V2],1,[])
V = V(3:end)
results in:
V1 =
3 8 6 7
V2 =
1 5 9 4
V =
3 1 8 5 6 9 7 4
V =
8 5 6 9 7 4

추가 답변 (2개)

Nora Khaled
Nora Khaled 2020년 11월 24일
v1 = [3 8 6 7];
v2 = [1 5 9 4];
r=[];
for i=2:1:length(v1)
r=[r v1(i) v2(i)];
end
r

Eva Maria Leal Munoz
Eva Maria Leal Munoz 2020년 11월 24일
Thanks very much both!

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by