Extracting data from several columns by indexing?
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi, I'm a bit new with MatLab and my problem concerns extracting and indexing. I have a large datafile, which has columns month, day, hour, minute, measurement1, measurement2...measurementN e.g.: data=
[2009 1 1 10 100 120 150 120 120
2009 1 1 10 362 323 300 554 654
2009 1 1 11 419 540 640 550 540
...]
I need to extract data at certain hour (e.g. 10) from all columns. (With excel this would be sorting with hour = 10.) I tryed indexing, but I managed only get data from one column not all. How can I extract all hour10 rows from all columns?
Thank you for your help, Liisa
댓글 수: 0
채택된 답변
Oleg Komarov
2011년 8월 1일
idx = data(:,4) == 10;
data(idx,:)
% Or specific columns
cols = [1:4 7,9];
data(idx,cols)
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!