Azzera filtri
Azzera filtri

Xlsread and Strcuture

2 visualizzazioni (ultimi 30 giorni)
KKR
KKR il 24 Mar 2011
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

Risposte (3)

the cyclist
the cyclist il 24 Mar 2011
For your second question, try
doc dataset
to read about dataset arrays, which may help you.

Kaustubha Govind
Kaustubha Govind il 1 Apr 2011
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.

mohammed
mohammed il 1 Apr 2011
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));

Community Treasure Hunt

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

Start Hunting!

Translated by