Searching and Manipulating Cell Array - Part 2
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Matt J
el 20 de Oct. de 2012
Editada: Matt J
el 20 de Oct. de 2012
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
el 20 de Oct. de 2012
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?
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Types en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!