Reading multiple number of an EXCEL file without knowing number of rows and columns

1 回表示 (過去 30 日間)
Hello, in the code below i have to specify the range for columns but i have 100 set of excel files in that with different column length so how to specify in that case
[~, ~, raw]= xlsread(fullFileName,'Results','B3:1000');

採用された回答

Jeff Johnson
Jeff Johnson 2014 年 4 月 2 日
Assuming the data you are interested in is always in column B:
[~,~,raw]=xlsread(fullFileName,'Results','B:B'); % reads all rows in Column B
raw(any(cellfun(@(x) any(isnan(x)),raw),2),:) = []; % removes all NaN entries
This code will leave you with a cell array with the raw data for all non-empty cells in column B. As written it will read all of the rows (65,536 of them!) in each file. If you know the maximum number of non-empty rows in all files (say 1500), you could speed this up by replacing 'B:B' with 'B1:B1500'.
This thread contains more information about deleting rows with NaN entires.
  3 件のコメント
Yogesh Babu
Yogesh Babu 2014 年 4 月 3 日
編集済み: Yogesh Babu 2014 年 4 月 3 日
Hello ,
After this I would like to plot them but that is not working in plotting them.Have a look and tel me the solution for this problem
[~,~,raw]=xlsread(fullFileName,'Results','B:B'); % reads all rows in Column B raw(any(cellfun(@(x) any(isnan(x)),raw),2),:) = []; % removes all NaN entries Blob = data(:,1); Area = data(:,2); clearvars data raw; h=bar(Area);figure(gcf);
Jeff Johnson
Jeff Johnson 2014 年 4 月 4 日
Hi Yogesh,
What is the data variable you are referencing? Can you also include the error message returned when you try to plot these data?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by