How can I remove rows in a matrix with a range of value that I do not want?
조회 수: 17 (최근 30일)
이전 댓글 표시
Hi sorry if this is a simple question but I am struggling to work my script. I have a huge dataset with over 40 million points and 20 columns. One is for depth and I am trying to remove values above 6m and below 10m and only keep the rows which have a range of -10m to -6m in depth (depth is in column 4).
I have this so far but i am unsure what to do next and I am really struggling in trying to source a range of values.
clc
close all
Z=readmatrix('filename.txt');
%z = (Z>-6.0);
%z = (Z()<-10.0);
Z(Z(:,4)>-6.0) = NaN;
Z(Z(:,4)<-10.0) = NaN;
Z(any(isnan(Z),:20),:) = [];
Many thanks for any help.
댓글 수: 0
채택된 답변
Walter Roberson
2020년 1월 12일
depth = Z(:, 4);
mask = depth >= -10 & depth <= -6;
Z = Z(mask, :);
댓글 수: 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!