what does data_gt(:,7) == 1, :) do in Matlab?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Tianyu Cheng
am 27 Nov. 2020
Kommentiert: Tianyu Cheng
am 27 Nov. 2020
data_gt = data_gt(data_gt(:,7) == 1, :);
what does data_gt(:,7) == 1, : do?
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!