How can I change a variable's name to an excel sheet name?
Show older comments
I'm sure there is an easy answer to this, but I haven't used Matlab in a while and am a bit rusty.
I am wanting to import data from an excel file with multiple sheets, then name each variable the sheet name. Here's what I have so far, but maybe there is a better way...
[STATUS, SHEETS] = xlsfinfo('022117_EIS_Data.xls'); % Use user selected info
isempty = zeros(61,5);
for i = 1 : max(size(SHEETS))
isempty = xlsread('022117_EIS_Data.xls',i);
end
Basically I was hoping to rename 'isempty' every loop as the current excel sheet (saved in SHEETS)
1 Comment
Naming variables dynamically is one way that beginners force themselves into writing slow, complex, buggy code that is hard to debug. Read this to know why:
If the sheets names are significant then this means that they are contain meta-data, and meta-data should simply be stored as data in their own right (e.g. in a cell array.
Accepted Answer
More Answers (0)
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!