Can one save the filename as a variable in 'readtable'?
Ältere Kommentare anzeigen
Suppose I use
T=readtable('texas,csv')
I want to save the name of the file (texas) as a variable. Please advise.
1 Kommentar
alpedhuez
am 29 Nov. 2020
Akzeptierte Antwort
Weitere Antworten (1)
Ameer Hamza
am 28 Nov. 2020
Bearbeitet: Ameer Hamza
am 28 Nov. 2020
you can save char arrays in a variable and then concatenate it with the extension using [] operator.
filename = 'texas';
T = readtable([T '.csv'])
5 Kommentare
alpedhuez
am 28 Nov. 2020
Ameer Hamza
am 28 Nov. 2020
You can use fileparts()
filename = 'texas.csv';
[~, name, ext] = fileparts(filename)
alpedhuez
am 28 Nov. 2020
Ameer Hamza
am 29 Nov. 2020
Are you trying to name the variables named like texas, iowa, etc. For example
filename = 'texas';
texas = readtable([T '.csv'])
This is not a good coding approach: https://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval
alpedhuez
am 29 Nov. 2020
Kategorien
Mehr zu C2000 Microcontroller Blockset finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!