How make the number of columns of two matrices equal?

4 views (last 30 days)
how I make the number of columns for two matrices equal in the code IF I have code generate data with matrix 20X 5000 and another matrix with size 61X6100 when I want to concatenate a row array with a column array? if any one help me please.

Answers (1)

Steven Lord
Steven Lord on 27 Sep 2022
There are a number of possibilities. Off the top of my head:
  • You could discard 1100 columns of the second matrix (the first 1100, the last 1100, half from the left and half from the right, etc.)
  • You could pad the first matrix with 1100 more columns (full of all 0 values, full of NaN values, duplicates of 1100 columns from that matrix, etc.)
  • You could interpolate one of the matrices so that they span the same "range" as the original but the spaces between columns is different (take hourly data and interpolate it to data with spacing of a minute, for example.)
What is the (or a) correct solution for your data depends on what it represents and how the two matrices relate to one another.


Find more on Matrices and Arrays in Help Center and File Exchange


Community Treasure Hunt

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

Start Hunting!