Searching and Manipulating Cell Array - Part 2
1 回表示 (過去 30 日間)
古いコメントを表示
This is a new problem but the problem data is similar.
I have a cell array A:
[3,2]
[2,4]
[4,5]
[2,5]
[6]
and cell array B:
[2,3,4]
[2,6]
[4,5,6]
In the array B I can see that [2,3,4] is made of elements from [3,2] and [2,4] from A. So, I will assign these two elements from A to B and remove them from A.
A now has:
[4,5]
[2,5]
[6]
[2,5] in B is made from elements of [4,5] and [2,5] from A. So, we assign [4,5] and [2,5] to second element of B and so on. Please observe in second example that 4 was an extra element from A which was not present in B at all but still I want to assign [4,5] and [2,5] to second element of B. We delete them from A.
Now A has only:
[6]
So, how do I achieve this?
Thanks guys
2 件のコメント
Matt J
2012 年 10 月 20 日
編集済み: Matt J
2012 年 10 月 20 日
Quote: "[2,5] in B is made from elements of [4,5] and [2,5] from A."
B as you've listed it does not show a [2,5]. It does show a [2,6]
Also, even if B did include [2,5], it wouldn't require elements from [4,5] in A since the [2,5] in A completely covers the [2,5] in B.
Matt J
2012 年 10 月 20 日
Quote: "Please observe in second example that 4 was an extra element from A"
If extra elements don't matter, why not use all of A to cover B{1}. Also, what if there are multiple different ways to cover a B{i} with members of A? Does it matter which one we pick?
採用された回答
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!