MATLAB: Truncating rows from a matrix

truncation of speific rows from a matrix

I have a matrix of panel data with 23 cross sections and 144 time intervals. So total number of rows is 23*144=3312 in the matrix with 10 columns for ten variables. I need to get rid of few data from each of the cross sections. such as I want to discard 10th, 15th, 20th, 90th and 120th time-interval data from each each cross section so that I will have a matrix of 23*139=3197 rows. How can do it in MATLAB? Can anyone help?
Kind regards
Sayeed

Best Answer

Mohammad, not knowing exactly how your data is organized you could follow this path:
data = eye(12); % as an example I use a 12-by-12 unity matrix
dataC = cell2mat(mat2cell(data,4*ones(1,3),12).');
dataC([2 3],:) = []; % replace [2 3] by [10 15 20 90 120]
dataR = cell2mat(mat2cell(dataC,2,12*ones(1,3)).');
Using the mat2cell command, first reshape the matrix from a 23*144-by-10 to a 144-by-23*10. Eliminate the rows and convert back to a 23*139-by-10. In other words try
dataC = cell2mat(mat2cell(data,144*ones(1,23),10).');
dataC([10 15 20 90 120],:) = [];
dataR = cell2mat(mat2cell(dataC,139,10*ones(1,23)).');