Compare elements of cell array
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Tha saliem
el 2 de Abr. de 2017
Comentada: Tha saliem
el 2 de Abr. de 2017
HI I have a 2D array like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/162515/image.png)
and a cell array:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/162516/image.png)
I want to search elements of cell array in 1st column of 2D array. Like 2nd row of cell array has 4 and 3, it is present in 1st column of 2D array, it should display both rows (and all other elements as zero).
Thanks in advance.
5 comentarios
Stephen23
el 2 de Abr. de 2017
Editada: Stephen23
el 2 de Abr. de 2017
@Tha saliem: I notice that you are clearly using my code from your earlier question:
Is there a reason why you do not accept my answer... even though you are using my answer?
Also it would be much easier if you actually told us what you are trying to achieve, rather than trying to solve these small tasks. Then we could help you to develop a solution for your main task, rather then waste time trying to figure out solutions (that you do not accept) to every small task:
Respuesta aceptada
the cyclist
el 2 de Abr. de 2017
M = [0 1
1 0
2 1
3 0
4 1
5 0
6 0];
C = {[];[4;3];[3;1;4];2;[1;3;2;4];5;5};
output = cellfun(@(x)M(sort(x),:),C,'UniformOutput',false);
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrix Indexing 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!