Inserting a column in a matrix before adding it to another matrix in a loop

2 ビュー (過去 30 日間)
Jiwoo Seo
Jiwoo Seo 2020 年 10 月 7 日
編集済み: James Tursa 2020 年 10 月 7 日
Hi all,
As the title says, I'm trying to insert a column in matrix B (B1, B2, B3) before adding it to matrix A to account for a column that already exists in matrix A.
Here's an example the vertical matrix that I have:
A =[1
2
3]
In this vertical matrix, I want to add matrices that are horizontal, but have it start at the second column. Like so:
%these are the matrices that will be added to A.
B1=[34 35 36 37];
B2=[48 49 30 21];
B3=[24 33 23 22];
%C is the final matrix that I want to have.
C=[1 34 35 36 37
2 48 49 30 21
3 24 33 23 22]
How do I add the horizontal matrices to the vertical matrix from the second column?

回答 (1 件)

James Tursa
James Tursa 2020 年 10 月 7 日
編集済み: James Tursa 2020 年 10 月 7 日
C = [A,[B1;B2;B3]];

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by