Write out rows which have cell with specific value from large array in MATLAB

조회 수: 2 (최근 30일)
John
John 2013년 3월 13일
I am reading in data from a large array (~50000 x 45). I am trying to extract rows from this which have their x_value (column 27) above a specific value (1.8 in this case).
I am able to write the array (p1) but each output row is the same, (the last row from the large array with x > 1.8)
Can anybody tell me how to write out this data properly?
Thanks
n = length(DAT);
bin = 1.8;
x_value = DAT(:,27);
row = sum(x_value > bin);
for s = 1:n;
if DAT(s,27) > bin
for r = 1:row;
p1(r,:) = DAT(s,:);
end
end
end

답변 (1개)

Matt J
Matt J 2013년 3월 13일
편집: Matt J 2013년 3월 13일
Make life easier on yourself with vectorized one-liners
p1=DAT(:,DAT(:,27) > bin);

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by