Merge parts that make up the string
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Alberto Acri
el 27 de Nov. de 2022
Respondida: dpb
el 27 de Nov. de 2022
Hello! I have a 1x5 string.
I would like to merge all the 5 parts that make up the string so that I have one overall string.
Between each string there must be a "_" symbol.
I have tried it this way
string_final = strcat(strPieces(1),"_", strPieces(2),"_", strPieces(3),"_", strPieces(4),"_", strPieces(5));
but I want to get the same result with something more generic and that can be directly referenced to the value 5 (as it might change).
For example:
number_of_string = 5;
string_final = strcat(strPieces(1:number_of_string), "_");
0 comentarios
Respuesta aceptada
dpb
el 27 de Nov. de 2022
S=string(['A':'E'].'); % an arbitrary array of strings
join(S,"_") % join with underscore character
0 comentarios
Más respuestas (0)
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!