Combining variables
Ältere Kommentare anzeigen
I have written a code that generates 20 strings (the number actually varies depending on the input), all of which have the names "s_idx_?" where ? is a number from 1 to 20. Is there a command that allows me to concatenate all these strings without having to type out all the names? Thanks.
5 Kommentare
Nathan Greco
am 19 Jul. 2011
First: it is generally nicer to create one data structure to contain all of these strings rather than creating a variable per string. Look up cell arrays, they are your friend. Rather than calling your strings s_idx_?, you could just call them s{?} where ? is your old number.
E. Elgar
am 19 Jul. 2011
Sean de Wolski
am 19 Jul. 2011
POISON!! EVAL!! Don't do it!!
E. Elgar
am 20 Jul. 2011
Akzeptierte Antwort
Weitere Antworten (1)
Kategorien
Mehr zu Variables finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!