MATLAB Answers

Matrix creation combining vectors

조회 수: 6(최근 30일)
giometar
giometar 30 Jan 2020
댓글: giometar 30 Jan 2020
Hello
I have two vectors V1 and V2 which I want to combine in one matrix M (size V1*V2,2):
V1=[1 2 3 4 5 6];
V2=[5 10 15];
M=[1 5;2 5;3 5;4 5;5 5;6 5;
1 10;2 10;3 10;4 10;5 10; 6 10;
1 15;2 15;3 15;4 15;5 15;6 15];

  댓글 수: 0

Sign in to comment.

채택된 답변

Adam
Adam 30 Jan 2020
편집: Adam 30 Jan 2020
M = [ repmat( V1(:), [numel(V2), 1] ), repelem( V2(:), numel( V1 ) ) ];

  댓글 수: 1

giometar
giometar 30 Jan 2020
Thank you very much.

Sign in to comment.

추가 답변(0개)

태그

제품


Translated by