'ab[c]' to this 'ab_c' ?
Mostra commenti meno recenti
How can I convert this 'ab[c]' to this 'ab_c' ?
The letters a,b,c are for the specific example.
In the position of c could be any letter.
2 Commenti
Steven Lord
il 6 Nov 2021
Modificato: Steven Lord
il 6 Nov 2021
Are you trying to change a char vector containing this literal text, or are you trying to change indexing into a variable to instead have numbered names for variables?
If the latter, can you define variables with numbered names like ab_1, ab_2, ab_3, ... ? Yes. Should you do this? Generally we recommend against it. See that page for alternatives you should use instead.
Ioannis Vourvachakis
il 6 Nov 2021
Modificato: Ioannis Vourvachakis
il 6 Nov 2021
Risposta accettata
Più risposte (1)
C = { '10fthf[c]'
'10fthf[h]'
'10fthf[m]'
'10fthf[x]'}
cellstr(extractBefore(string(C),"[") + "_" + extractBefore(extractAfter(string(C),"["),2))
1 Commento
Ioannis Vourvachakis
il 6 Nov 2021
Categorie
Scopri di più su Characters and Strings in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!