필터 지우기
필터 지우기

How to select columns in a matrix of variable size?

조회 수: 2 (최근 30일)
Cameron Spooner
Cameron Spooner 2016년 8월 28일
편집: Azzi Abdelmalek 2016년 8월 28일
I have a matrix that I am trying to split into two separate matrices. The original matrix is composed of an unknown number of columns but will always be divisible by 3. I am trying to create a new matrix composed of the 1st column of the original matrix and then every 3rd column after that. E.g. Columns 1,4,7,10.....
I am also trying to create a new matrix that is composed of all of the columns not counted in creating the other new matrix. E.g. Columns 2,3,5,6,8,9.....
How would I go about doing this?

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 8월 28일
편집: Azzi Abdelmalek 2016년 8월 28일
m=size(A,2)
B=A(:,1:3:m)
C=A(:,setdiff(1:m,1:3:m))

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 System Composer에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by