I have an excel file with one column of dates and several columns of data (there are some #N/As, but xlsread doesn't have a problem).
Anyway, I have some code that imports the data and then creates a dataset array with different Vars for each series (rather than as one big array). I've tried other ways to do this directly through the dataset function since it seems to say it can do something similar to this in the documentation. However, I have never been able to get it to work. For instance, if I just run: a=dataset('XLSFile',file,'ReadVarNames',true,'ReadObsNames',true);
then I get the following error:
??? Error using ==> setvarnames at 26 NEWNAMES must be a nonempty string or a cell array of nonempty strings.
Error in ==> dataset.dataset>readXLSFile at 723 a = setvarnames(a,varnames(:)'); % names will be modified to make them valid
Error in ==> dataset.dataset>dataset.dataset at 353 a = readXLSFile(a,xlsfileArg,otherArgs);
Anyway, I tried a bunch of combinations, but could never get it to work. (I thought converting the date strings in excel to numbers would work or using the actual ObsNames I already imported, but no luck).
This is the code I use currently:
file=strcat(setdir,source);
[num,txt,~]=xlsread(file);
name=txt(1,:);
date=txt(2:end,1);
date_val=datenum(date(:));
num={[date_val num]};
data=dataset([num,name{:}],'ObsNames',date);