Remove elements from string array
16 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
What is the simpest way to remove string elements from an array? e.g. arr = [1, 2, 3, "x", "y", 10] would turn into [1,2,3,10]
4 comentarios
Guillaume
el 26 de Nov. de 2019
What is the rule that dictates which elements should be removed from the string array?
Respuestas (1)
Guillaume
el 26 de Nov. de 2019
One possible way:
numericarray = double(yourstringarray); %convert string array to numeric. Text that can't be converted to numeric will end up as NaN.
numericarray = numericarray(mod(numericarray, 1) == 0); %only keep numbers that are integers. Will also remove NaNs.
0 comentarios
Ver también
Categorías
Más información sobre Characters and Strings 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!