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

2 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by