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

1 vue (au cours des 30 derniers jours)
Jiwoo Seo
Jiwoo Seo le 7 Oct 2020
Modifié(e) : James Tursa le 7 Oct 2020
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?

Réponses (1)

James Tursa
James Tursa le 7 Oct 2020
Modifié(e) : James Tursa le 7 Oct 2020
C = [A,[B1;B2;B3]];

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by