delete an element from string
64 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mahdi Hayati
el 21 de Mayo de 2022
Respondida: ajay kumar
el 6 de Jul. de 2022
hi
I have this string:
str = ["a" "b" "c"]
which gives:
"a" "b" "c"
how can I have this new string with the previouse one:
new_str = "a" "c"
in other words, I want to delete "b" completely.
I have tried erase but with that I will have:
"a" "" "c"
thanks in advance.
0 comentarios
Respuesta aceptada
DGM
el 21 de Mayo de 2022
How do you intend to identify the thing you want to delete? Do you simply want to delete the second string in the array?
str = ["a" "b" "c"];
str(2) = []
Or do you want to delete all (or the first) instance of the string "b" in the array?
str = ["a" "b" "c"];
idx = strcmp(str,"b");
str(idx) = []
Más respuestas (1)
ajay kumar
el 6 de Jul. de 2022
str = ["a" "b" "c"];
y= find(contains(str,"b"))
str(y) = []
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!