How to insert rows into a matrix

1 Ansicht (letzte 30 Tage)
Elaheh am 14 Dez. 2018
Kommentiert: Mohsin Shah am 15 Apr. 2019
I have a matrix (748*6). I need to insert one row after every 3rd row. How should I do that? the resulting martix should be (1126 *6).
Thank you
  2 Kommentare
Elaheh am 14 Dez. 2018
apologize for not being clear. This is one part of data. Current table is on the right and the one I need to create is on the left. Capture.PNG

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Jan am 14 Dez. 2018
If the details with the size of the output are cleared, something like this will solve the problem:
A = rand(748, 6); % Test data
n = 3; % In each 3rd row
m = true(748 / (n-1) * n, 1);
m(n:n:end) = false;
B = zeros(numel(m), 6);
B(m, :) = A;

Weitere Antworten (0)


Mehr zu Shifting and Sorting 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