find column from list then save cell
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Vincent I
el 23 de Jun. de 2014
Comentada: Vincent I
el 24 de Jun. de 2014
Hi,
I have two cells:
A = {'One','Four','Five'};
B = {'One','Two','Three','Four','Five';1 2 3 4 5;6 7 8 9 10};
Find A in B = C
C = {'One','Four','Five';1 4 5;6 9 10}
As shown above, I would like find the columns from A in B and the save them to another cell C without using either a for or while loop.
Cell A can have different numbers so whats shown above its not always the same.
Thank you
0 comentarios
Respuesta aceptada
Más respuestas (1)
Azzi Abdelmalek
el 23 de Jun. de 2014
A = {'One','Four','Five'};
B = {'One','Two','Three','Four','Five';1 2 3 4 5;6 7 8 9 10};
If you work with tables
BB=cell2table(B(2:end,:),'VariableNames',B(1,:))
C=BB(:,A)
Ver también
Categorías
Más información sobre Cell Arrays 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!