How to find corresponding indices?
조회 수: 8 (최근 30일)
이전 댓글 표시
Good Day,
I have a dataset I am working (891 rows,12 columns) with and have already sorted one column with zeros and ones (Logical). I would now like to pull data from 2 other columns (number and text) where the ones are located (neglecting the zeros). How can I write this in matlab?
TIA!
댓글 수: 0
답변 (1개)
Voss
2022년 11월 9일
% some data
data = [0 10]+(1:10).'
% whether to get each row:
rows_to_get = [false; false; true; true; false; false; false; true; true; false]
% final result:
result = data(rows_to_get,:)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!