Borrar filtros
Borrar filtros

How to add to create matrix by combining two columns

55 visualizaciones (últimos 30 días)
Thallon Pitchure
Thallon Pitchure el 29 de Ag. de 2020
Respondida: Bruno Luong el 29 de Ag. de 2020
Hello! I am trying to do some matrix expansion. I have two columns of data that I have label as h and newCol. They both include 10 rows. My question is how to take these vectors and put them in a single 10x2 matrix. I have tried using newMat = [newCol; h] and the output is a single column with 20 rows. I also tried newMat = [newCol(:); h(:)] and had similar results. I am unsure what I am doing wrong.

Respuestas (2)

Hussein Ammar
Hussein Ammar el 29 de Ag. de 2020
Use horzcat, e.g.,
A=[1;2;3];
B=[4;5;6];
C= horzcat(A,B)

Bruno Luong
Bruno Luong el 29 de Ag. de 2020
newMat = [newCol, h]

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by