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

1 visualización (últimos 30 días)
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?

Respuestas (1)

James Tursa
James Tursa el 7 de Oct. de 2020
Editada: James Tursa el 7 de Oct. de 2020
C = [A,[B1;B2;B3]];

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by