Create an array from another and find the indices.
Mostrar comentarios más antiguos
Hi everyone,
I have an array with variables like S,SV, V etc now I want to create a new array only with the V variable so for example;
V
SV
S
V
will become
V
V
after this I need to know the indices where I found each one of the V variables, so in this example I should get Indices = 1 and 4
Thank you for the help.
2 comentarios
Walter Roberson
el 11 de Feb. de 2014
Are those strings, or are they numeric values? If they are numeric values, are they scalars or vectors or arrays? If they are vectors or arrays are all of them the same size?
João
el 11 de Feb. de 2014
Respuesta aceptada
Más respuestas (2)
Walter Roberson
el 11 de Feb. de 2014
find( ismember('V', most_common_string))
1 comentario
João
el 11 de Feb. de 2014
David Sanchez
el 11 de Feb. de 2014
most_common_string = {'V','SV','S','V','S'};
wanted_string='V';
idx = getnameidx(most_common_string,wanted_string);
idx = find(most_common_string==wanted_string);
k=1;
for i=1:numel(most_common_string)
if most_common_string{i} == 'V'
periodo(k)=i;
k = k+1;
end
end
periodo =
1 4
new_string_array = most_common_string(periodo);
new_string_array =
'V' 'V'
1 comentario
João
el 11 de Feb. de 2014
Categorías
Más información sobre Resizing and Reshaping Matrices 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!