Help in making code involving strings and cell array simpler and run faster
Mostrar comentarios más antiguos
Dear All,
Is there any to make this code simpler? It involves detecting a value a from a string to see if it is equal to value in a cell array and then recording the index of the string the value is contained in. i.e if xx=[1,2,3] and a = [{1,98,99} {1,2,6,} {4,5,6} {7,8,9} {3,45,78}], then y should equal [1,2,5] as those strings contain th values in the xx.
a=groups;
xx=string;
y=[];
for i = 1:length(a)
for j = a{i}
for k = xx
if k == j
y = [y i];
end
end
end
end
y = unique(y);
Sorry if I am not clear in asking this question, I have only been doing Matlab for a short time.When i have tried to run this code using the a and xx i have, it simply runs on and on without giving an answer or error.
Kind Regards,
Blixan
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Cell Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!