Print String Names to be used for Variable Names?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I have a function that lists filenames in a vertical array of strings.
fileArray = {'file1'
'file2'
'file3'}
Say I want to assign values and have the variable titled file2. I was thinking one could do it like:
disp(fileArray{2}) = 7
to make:
file2 = 7
But this doesn't seem to work. Any alternative suggestions?
3 Commenti
Stephen23
il 2 Giu 2017
Modificato: Stephen23
il 2 Giu 2017
Sure. Use a numeric matrix, if that works for your data. Else consider a numeric ND array, or a cell array, or a table, or a structure, or...
Accessing and processing data in one array is going to be a lot simpler than trying to do the same with lots of separate variables. As a general rule of thumb keep your data together as much as possible and your code will be much simplified.
Risposte (0)
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!