フィルターのクリア

find new matrix whose rows summation is between two integers

1 回表示 (過去 30 日間)
Nasser Hakami
Nasser Hakami 2019 年 11 月 21 日
コメント済み: Nasser Hakami 2019 年 11 月 21 日
I have a matrix A of size (nx9). I need to keep only rows who has row summation (m) between two integers number k=130 and c=135
as below example i am doing the solution manually. but i need to do auomatically because my original matrix size is (8760x9)
A =[7 16 42 8 49 0 2 0 8;
7 16 42 8 28 0 2 0 11;
7 16 42 8 49 0 2 0 8;
1 6 42 8 28 45 6 5 6;
7 16 42 8 49 0 2 0 8;
9 14 42 32 28 0 2 0 4;]
row1_sum = 132 ; row2_sum = 114; row3_sum =132; row4_sum =147; row5_sum =132; row6_sum=131
so the new matrix is
B=[a(1,:); a(3,:); a(5,:); a(6,:)]
B =[7 16 42 8 49 0 2 0 8
7 16 42 8 49 0 2 0 8
7 16 42 8 49 0 2 0 8
9 14 42 32 28 0 2 0 4]

採用された回答

JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH 2019 年 11 月 21 日
solution:
B=A(and(sum(A,2)>=130,sum(A,2)<=135),:)
  2 件のコメント
Nasser Hakami
Nasser Hakami 2019 年 11 月 21 日
thanks a lot
amazing . simple and perfect
Nasser Hakami
Nasser Hakami 2019 年 11 月 21 日
i realy appreciate if you can have look to
I got a correct answer but it is doing many functions and it is very slow if i increase the apples to 40, my labtop stop working also .

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by