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

 Réponse acceptée

Walter Roberson
Walter Roberson le 27 Nov 2020
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.

Plus de réponses (0)

Catégories

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by