How could I extract the first two columns, and leave the next two and then so on from a matrix
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Salman Ahmad
am 5 Aug. 2019
Kommentiert: Salman Ahmad
am 5 Aug. 2019
for example I have 100 columns, then how could I extract the first two and then leave the next two columns like this (1,2,5,6,9,10,13,14,..............97,98)..
0 Kommentare
Akzeptierte Antwort
Joel Handy
am 5 Aug. 2019
Bearbeitet: Joel Handy
am 5 Aug. 2019
% Set up example data set
A = eye(100);
A(1,:) = 1:100;
numCols = size(A,2);
% Answer
B = A(:,sort([1:4:numCols 2:4:numCols]));
% Verification
size(B)
B(1,:)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping 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!