Merge parts that make up the string
2 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
dpb
on 27 Nov 2022
S=string(['A':'E'].'); % an arbitrary array of strings
join(S,"_") % join with underscore character
0 Comments
More Answers (0)
See Also
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!