Creating variables based on number of columns?

7 views (last 30 days)
So I have a project I am working on, and I have to import an excel sheet where the first column is just dates, and every column after that contains data with the first row containing the name of the data. How can I in my script create varibles for each column, and have it be expandable? Lets say I have to use a different data sheet that only have 5 columns instead of 8. What would be the best way to go about doing this? I also need to manipulate the data but I have no idea how to even assign the data to variables to manipulate it.

Accepted Answer

Steven Lord
Steven Lord on 13 Apr 2020
How can I in my script create varibles for each column, and have it be expandable?
CAN you do this? Yes. SHOULD you do this? NO.
Instead I recommend reading your data into a table or timetable array using either readtable (possibly calling table2timetable on the resulting table) or (if you're using release R2019a or later) readtimetable. There are a number of ways to access the data in a table or timetable, including selecting a set of rows in a range of times, for timetable arrays.

More Answers (0)

Categories

Find more on Tables in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!