Xlsread and Strcuture
2 次查看(过去 30 天)
显示 更早的评论
Hi Guys,
Hope you are all doing fine. I have two primary questions, as I am a new user to MATLAB, and could not find satisfactory answer in help files.
1, I am trying to import data from excel file and I basically need flexibility in terms of user, will define the number of worksheet he wants data from. All worksheets has different no. of rows and I am wondering how can i use END argument in xlsread function, to make sure user will be able to import all the raws. For example, I have the following for one worksheet:
cstr = xlsread('opt56.xls',1,'B1:B47545');
And I would like to change that argument to ensure that everything is covered. B1:B:End ...something like that, not sure of exact syntax.
2, I used to use s-plus(similar to R), all the time for my statistical purpose, and now I am getting my hands on MATLAB. But facing a problem of working with Matrices as opposed to data frames as for dataframe I could simply refer to column with their names and have text and numbers in same dataframe. Of course I can have vectors in matlab and use them by their names/titles, but not with whole matrix and thus sometimes filtering of data becomes cumbersome. I am sure, MATLAB structure would be helpful to over come this problem, but I need some help on using structure for this purpose. My data is not that complex, its for regression purpose, so basically I have titles and column vectors. Any help?
Thank you for having such a great active community.
Kaushal
0 个评论
回答(3 个)
the cyclist
2011-3-24
For your second question, try
doc dataset
to read about dataset arrays, which may help you.
0 个评论
Kaustubha Govind
2011-4-1
To answer your first question - I don't think there is a MATLAB function to help with this, but you might be able to use the Excel COM API by starting it as a COM server from MATLAB, to find the range of a column.
0 个评论
mohammed
2011-4-1
for your first question
in your excel file store the number of rows using count function at cell for example "a1" use the following code to get your data
EOF = xlsread('data1.xls', 1, 'a1');
StartRange={'a2'};
EndRange={':a'}
Range=strcat(StartRange,EndRange,num2str(EOF));
targets = xlsread('data1.xls', 1, char(Range));
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!