how to join 3 strings into single string?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
chocho
el 2 de Abr. de 2017
Comentada: chocho
el 2 de Abr. de 2017
I have a cell array [1*3 cell] Example Tcgh A6 1214 and i want to join them by put '-' in between and get Tcgh-A6-1214
i tried strcat and strjoin but doesn't work with me! Thanks
0 comentarios
Respuesta aceptada
Más respuestas (1)
Nicolaie Popescu-Bodorin
el 2 de Abr. de 2017
res = strCell{1};
for k=2:length(strCell),
res=[res '-' strCell{k}];
end;
disp(res);
1 comentario
Stephen23
el 2 de Abr. de 2017
This expands the output res on each iteration, which is not efficient:
See my answer for a simpler and more efficient solution that does not use a loop.
Ver también
Categorías
Más información sobre Loops and Conditional Statements 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!