How to store values of rows in a matrix where the 3rd column is a multiple of 100?

조회 수: 1 (최근 30일)
I have a matrix with 3 columns and a large number of rows. In order to reduce the rows, I need to keep the rows whose 3rd column value is a multiple of 100 and store it in as a new matrix. How do I do that?

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 12월 5일
편집: Ameer Hamza 2020년 12월 5일
Use can use rem() to filter the rows where the third column is multiple of 100 and then use logical indexing
M; % nx3 matrix
idx = rem(M(:,3),100)==0;
M_new = M(idx, :);

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by