How can I add a column to existent 3D matrix

6 Ansichten (letzte 30 Tage)
Mario
Mario am 9 Mai 2020
Kommentiert: Mario am 11 Mai 2020
Hi,
How can I add a specific column to an existent 3D matrix, as in this example?
A = 180 x 360 x 107 (MxNxt)
and I would like to add the first column from N (360) at the end of N to get 361 columns instead, thus to end with
B = 180 x 361 x 107 (MxNxt)
Thank you!

Akzeptierte Antwort

James Tursa
James Tursa am 9 Mai 2020
First, you need to realize that the size of your insert will be 180 x 1 x 107. I.e., it is not just a 180 element column you need to insert, but 107 of these columns ... one for each third dimension. I'm not sure what exactly you are trying to insert, but the general syntax would be
B = A;
B(:,361,:) = your 180 x 1 x 107 insert;
Or if you have a single column that you want repeated, you could employ repmat( ) on the right hand side.
What exactly are you trying to insert?
  1 Kommentar
Mario
Mario am 11 Mai 2020
That is exactly what I was looking for, add the first column (180,1,107) into the original 3D matrix (180,360,107), to create (180,361,107), thank you so much!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by