How do I add variables into a string within a table?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Nick O'Connor
il 20 Ott 2020
Commentato: Star Strider
il 20 Ott 2020
I have a table with a column of 10 digit strings that I need to add "-" into.
How do I turn a column of strings looking like this "0001336363" into a column of strings looking like this "0001336-36-3"?
0 Commenti
Risposta accettata
Star Strider
il 20 Ott 2020
The only option appears to be to turn the string variable into a char array first:
str = "0001336363";
strc = char(str);
Out = sprintf("%7s-%2s-%s", strc(1:7),strc(8:9),strc(10))
producing:
Out =
"0001336-36-3"
.
2 Commenti
Star Strider
il 20 Ott 2020
As always, my pleasure!
I searched through the string functions, although I didn’t consider that insertAfter would apply. It would likely come down to which is the more efficient use of computer resources.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Characters and Strings in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!