フィルターのクリア

Matrix value comparision and manipulation

1 回表示 (過去 30 日間)
anshuman mishra
anshuman mishra 2019 年 12 月 16 日
編集済み: anshuman mishra 2019 年 12 月 16 日
i have a matrix C=
21 14 7 0
18 11 4 3
15 8 1 6
12 5 2 9
9 2 5 12
6 1 8 15
3 4 11 18
0 7 14 21
smallest element amongst the rows: D= 0 3 1 2 2 1 4 0
Smallest element amongst columns: E= 0 1 1 0
whenever the 1st element of E is matched with first element of D ,then assign 1, then the 2nd element of E should match 2nd element of D, if not assign 0.then 2nd element of E which is not yet matched is compared with 3rd element of E & so on.
FINAL OUTPUT : 1 0 1 0 0 1 0 1

採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 12 月 16 日
編集済み: KALYAN ACHARJYA 2019 年 12 月 16 日
C=[21 14 7 0
18 11 4 3
15 8 1 6
12 5 2 9
9 2 5 12
6 1 8 15
3 4 11 18
0 7 14 21];
D=min(C')
E=min(C);
result=ismember(D,E)
#Final_Output:
result =
1×8 logical array
1 0 1 0 0 1 0 1
  3 件のコメント
Steven Lord
Steven Lord 2019 年 12 月 16 日
Why is the fourth element of the output 0 instead of 1? The minimum element in the fourth row of C is the 2 in the third column, which happens to be one of the instances of the minimum element in the third column?
What rule are you following that makes the answer [1 1 1 0 1 1] instead of [1 1 1 1 1 1] or [1 1 0 1 1 1]?
anshuman mishra
anshuman mishra 2019 年 12 月 16 日
編集済み: anshuman mishra 2019 年 12 月 16 日
smallest element amongst the rows: D= 0 1 2 2 1 0
Smallest element amongst columns: E= 0 1 2 1 0
So here
0 matches with 0 , so we assign 1
1 matches with 1 , so we assign 1
2 matches with 2 , so we assign 1
1 doesnt match 2, assign =0
so here before going to next element of E after 1 i.e 0, we need to match 1 of E with next element of D i.e 1
1 matches with 1, assign 1
0 matches with 0, assign 1
So final cost = 1 1 1 0 1 1

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by