Below is my 140*142 matrix. All odd columns (1,3,5...) are fixed code numbers for different systems. All even columns (2,4,6..) are time (durations) for each system. So for every value of an odd column (for example 1) there are 70 values. I want to remove all odd columns and just keep one column for fixed codes. and 70 columns for durations. My new matrix should be 140*72 shape. Any easy way to handle this problem in MATLAB?
New matrix
Fixed codes | dur 1 | dur 2|.... |dur 71
-15536 a b .. c
.
.
.
1001 x y .. z
Capture.PNG

 채택된 답변

Jon
Jon 2019년 6월 27일
편집: Jon 2019년 6월 27일

1 개 추천

Hi Devansh,
You can use basic MATLAB indexing to solve your problem, say your original matrix is given by A, then use
% generate column indices, to select first column and the columns 2,4,6..142
idx = [1 2:2:142]
% assign new matrix that has all of the rows in A ":", and just the columns "idx" that you want
B = A(:,idx)

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

릴리스

R2019a

질문:

2019년 6월 27일

댓글:

Jon
2019년 6월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by