How to get subset of data from given thresholds?

1 回表示 (過去 30 日間)
Macy
Macy 2023 年 2 月 28 日
コメント済み: Macy 2023 年 2 月 28 日
Please help, here is a snippet of code. There are three different thresholds that I have to make subsets of data for:
1)NZE > 0.25
2)NZE > 0.5, DNS < 30% of max DNS
3)NZE > 0.5, |Percent| < 20% (make sure to do absolute value)
I am not sure how to write out the last two. Because there are two boundaries, I am struggling on how to write it. If I had to guess I would do the following but I know it is not correct:
sub = dat(dat(:,10)>0.5,:)&dat(dat(:,9)<0.2*max(:;9),:);
sub = dat(dat(:,10)>0.5,:)&dat(abs(dat(:,11)<0.2,:));;
Thank you.
dat = load('something random');
dat(:,12) = 1:size(dat,1);
names = {'DNS' 'NZE' 'Percent'};
columns = [9 10 11];
for i=1:3
if(i==1) % NZE > 0.25 %}
sub = dat(dat(:,10)>0.25,:); %} This section is correct
dat_1 = sub; %}
end
if(i==2) % NZE > 0.5, DNS < 30% of max DNS
sub = %??? Not sure of how to do this
dat_2 = sub;
end
if(i==3) % NZE > 0.5, |Percent| < 20%
sub = %??? Not sure of how to do this
dat_3 = sub;
end

採用された回答

Askic V
Askic V 2023 年 2 月 28 日
編集済み: Askic V 2023 年 2 月 28 日
Did you try this approach?
DNS = dat(:,9);
NZE = dat(:,10);
PER = dat(:,11);
% 1.
sub = dat(NZE>0.25,:);
%2.
sub = dat( (NZE>0.5) & (DNS<0.3* max(DNS)), : );
% 3. check percent column (is it 20% or 0.2)
sub = dat( (NZE>0.5) & (abs(PER)<20), : );
  1 件のコメント
Macy
Macy 2023 年 2 月 28 日
I believe this worked, thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by