what does data_gt(:,7) == 1, :) do in Matlab?

data_gt = data_gt(data_gt(:,7) == 1, :);
what does data_gt(:,7) == 1, : do?

 채택된 답변

Walter Roberson
Walter Roberson 2020년 11월 27일

1 개 추천

data_gt(:,7) == 1
extracts column 7 from all rows of matrix data_gt . It then compares each of the values to the constant one, returning a logical vector with the same number of entries as there are rows in data_gt . Each entry will be logical value false or true
data_gt(data_gt(:,7) == 1, :)
takes that logical vector as input into a data_gt(INDEX, :) operation . Each entry in the vector that is true results in the corresponding entire row being selected for output, and each entry in the vector that is false results in the corresponding entire row not being selected for output. Therefore data_gt(data_gt(:,7) == 1, :) ends up outputing the rows of data_gt in which column 7 equals 1.

추가 답변 (0개)

카테고리

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

태그

질문:

2020년 11월 27일

댓글:

2020년 11월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by