Print String Names to be used for Variable Names?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Stephen23
am 2 Jun. 2017
Bearbeitet: Stephen23
am 2 Jun. 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.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!