combine 2 matrices to 1 matrix?

4 ビュー (過去 30 日間)
Nimasha Pilippange
Nimasha Pilippange 2022 年 2 月 19 日
編集済み: Nimasha Pilippange 2022 年 2 月 19 日
I have 2 matrices as A=[ 1 2 3 4 5] and B= [ 6 7 8 9 10] , How can I combine them so I can get C=[1 6 2 7 3 8 4 9 5 10]. I need for a large matrix. But first I will start with a small matrix.
Can anyone help?

採用された回答

Torsten
Torsten 2022 年 2 月 19 日
編集済み: Torsten 2022 年 2 月 19 日
N = numel(A);
C = zeros(2*N,1);
C(1:2:end-1) = A;
C(2:2:end) = B;
  1 件のコメント
Nimasha Pilippange
Nimasha Pilippange 2022 年 2 月 19 日
編集済み: Nimasha Pilippange 2022 年 2 月 19 日
Thank you for the reply. It works fine.

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

その他の回答 (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