I am trying to delete any rows that agree with the statement Componentry_Analysis(:,6) == 1 and Componentry_Analysis(:,7) < 5, but I am unsure how to write an if statement with two statements and how to delete the rows if they agree with the statement.
My code so far:
[num_rows, num_cols] = size(Componentry_New_Mean);
for i=1:num_cols - 1
SD_Sort = Componentry_New_Mean(1:end,i) < 2;
Max_Sort= Componentry_New_Mean(1:end,i+1) < 6
Componentry_Analysis = [Componentry_New_Mean, SD_Sort, Max_Sort];
if Componentry_Analysis(:,6) == 1 and Componentry_Analysis(:,7) < 5
%delete rows
end
end
If anyone has any ideas that would be great?

 採用された回答

Voss
Voss 2022 年 5 月 19 日

0 投票

Here's a way to delete rows of a matrix if two conditions are both met:
x = magic(7)
x = 7×7
30 39 48 1 10 19 28 38 47 7 9 18 27 29 46 6 8 17 26 35 37 5 14 16 25 34 36 45 13 15 24 33 42 44 4 21 23 32 41 43 3 12 22 31 40 49 2 11 20
% delete rows of x where the value in column 6 is > 30
% and the value in column 7 is < 40:
x(x(:,6) > 30 & x(:,7) < 40,:) = []
x = 5×7
30 39 48 1 10 19 28 38 47 7 9 18 27 29 5 14 16 25 34 36 45 21 23 32 41 43 3 12 22 31 40 49 2 11 20

2 件のコメント

Daniel Gaggini
Daniel Gaggini 2022 年 5 月 19 日
Thank you
Voss
Voss 2022 年 5 月 19 日
You're welcome!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

リリース

R2022a

タグ

質問済み:

2022 年 5 月 19 日

コメント済み:

2022 年 5 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by