Assinging variable names to data read from files

Hello,
I am imporing tables of data from files and would like to automaticaly name the variables into which I assign the data so I can use it later for analysis.
When I use Live Editor to generate a script to import the data a unique variable name is used but the variable name is generated from the file name which is not good for me.
I can create the variable names using srtcat() or sprintf() but get an error when I try to assign the data.
Thanks

댓글 수: 1

Rik
Rik 2020년 7월 25일
The solution is simple: don't use automatically generated variable names. Metadata (such as the source file) is data itself. Store it as such. You can use a struct array with one field containing the source file name and another field containing the data itself.
Using arrays will allow you to easily manipulate your data and use loops and built-in operations on your data.

댓글을 달려면 로그인하십시오.

답변 (1개)

Star Strider
Star Strider 2020년 7월 25일

0 개 추천

Use readtable (R2013b and later versions) and then define a cell array of VariableNames to use with it.

카테고리

도움말 센터File Exchange에서 Structures에 대해 자세히 알아보기

질문:

2020년 7월 25일

댓글:

Rik
2020년 7월 25일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by