How to remove the row of matrix which contains same value in specific columns?

조회 수: 1 (최근 30일)
Abhinav
Abhinav 2018년 2월 8일
편집: KSSV 2018년 2월 8일
I have a dataset (just a subset of a larger dataset, attached excel file). In the dataset, I want to remove the rows which have 1 in 3rd and 4th column. How can I do it in MATLAB.

답변 (1개)

KSSV
KSSV 2018년 2월 8일
편집: KSSV 2018년 2월 8일
[num,txt,raw] = xlsread('delete_one.xls') ;
num(num(:,3)==1,:) = [] ; % remove rows with one in thrid column
num(num(:,4)==1,:) = [] ; % remove rows with one in fourth column
For flottant numbers better to use:
tol = 10^-3 ;
num(abs(num(:,3)-1)<tol,:) = [] ;
num(abs(num(:,4)-1)<tol,:) = [] ;

카테고리

Help CenterFile Exchange에서 Other Formats에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by