How could I extract the first two columns, and leave the next two and then so on from a matrix

조회 수: 10 (최근 30일)
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)..

채택된 답변

Joel Handy
Joel Handy 2019년 8월 5일
편집: Joel Handy 2019년 8월 5일
% 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,:)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by