How do I separate negative datas with their row?

1 回表示 (過去 30 日間)
Gary Ong
Gary Ong 2021 年 6 月 14 日
コメント済み: Gary Ong 2021 年 6 月 14 日
First 2 rows contain the long/lat;third row contains the land/water values. I want to separate the files into land and water xyz files for bathymetry use therfore I need the negative values from the 3rd column and their respective rows. I would like to extract the whole row of data containing negative numbers in any of the columns. It has 9135x3 cells of data. Any idea how to do this?

採用された回答

KSSV
KSSV 2021 年 6 月 14 日
編集済み: KSSV 2021 年 6 月 14 日
Let H be your third column.
idx = H<0 ; % get all negative values logical indices
lon1 = lon(idx) ;
lat1 = lat(idx) ;
H1 = H(idx) ;
If A is your data of size 9135x3.
iwant = A(A(:,3)<0,:) ;
  7 件のコメント
KSSV
KSSV 2021 年 6 月 14 日
H = SG1.(3); % Land/Water Values
J = SG1.(1); % Longitude
K = SG1.(2); % Latitude
idx = H<0 ;
lon1 = J(idx) ;
lat1 = K(idx) ;
h1 = H(idx) ;
Gary Ong
Gary Ong 2021 年 6 月 14 日
It worked! Thank you for your patience and guidance! @KSSV

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by