Matrix creation combining vectors

2 ビュー (過去 30 日間)
giometar
giometar 2020 年 1 月 30 日
コメント済み: giometar 2020 年 1 月 30 日
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];

採用された回答

Adam
Adam 2020 年 1 月 30 日
編集済み: Adam 2020 年 1 月 30 日
M = [ repmat( V1(:), [numel(V2), 1] ), repelem( V2(:), numel( V1 ) ) ];
  1 件のコメント
giometar
giometar 2020 年 1 月 30 日
Thank you very much.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by