xlsread and waitbar MATLAB

I have installed Matlab r2010a in my computer.

How to show updated progress in a waitbar figure while data is reading in parallel using xlsread function from matlab?

Thanks a lot for answering.

(EDIT)

what I mean is that while xlsread is loading the data one by one you can see the loading progress in waitbar.

Is there any way?

PD: I just want to load data from one *.xls file


ANSWERS:


There are a couple of options:

  1. A difficult option: create a .mex file and work out different MATLAB versions' undocumented memory representations (probably quite difficult, but I believe it's possible with some debugger).
  2. An easier way to do it: Create your own myxlsread.m using xlsread.m, xlsreadCOM.m and xlsreadXLSX.m as a point of departure.`
  3. If all you need is to update waitbar in a loop between consecutive xlsread commands, that's very easy.

1. The .mex file solution: If you want to show the progress of a single xlsread function call, I believe things get quite complicated. First, you would need to have two threads, and for that you would need to use .mex files or some other means. The second matter is that AFAIK xlsread doesn't send out any signals of its progress, which means that your .mex function would need to somehow get the memory addresses of the variables (cell arrays or matrices etc.) of the called xlsread function. If this is what you want, then this document would probably be useful: Do note that MATLAB's internal memory representation is completely undocumented and may change whenever and it's different in different MATLAB versions, so for a single waitbar this would be too much work.

2. The myxlsread.m solution: The good news is that xlsread is not a built-in (at least not in MATLAB R2012a) so you can read the code and trace it with MATLAB debugger without problems. As it's not a built-in what would be a possible option is creating your own custom myxlsread.m, by taking xlsread.m, xlsreadCOM.m and xlsreadXLSX.m as an example or by directly modifying them to add waitbar update function calls, if in your situation copyright problems are not an issue (eg. you don't distribute the code or local laws permit it). I think modifying or recreating your myxlsread.m is the most viable way to do it.

3. The xlsread in a loop solution: However, if all you want is to update waitbar between separate xlsread function calls, then that's not an issue at all, it would be something like:

XlsFilenamesCellArray = { 'file1.xls', 'file2.xls', 'file3.xls' };
NumberOfFiles = size(XlsFilenamesCellArray, 2)

h = waitbar(0, '1', 'Name', 'xlsread loop progress', 'CreateCancelBtn', 'setappdata(gcbf,     ''canceling'', 1)');

for Index = 1:size(XlsFilenamesCellArray, 2)
    waitbar(Index/NumberOfFiles, h, sprintf('reading .xls file %d of %d', Index, NumberOfFiles));
    [num{Index}, text{Index}, raw{Index}] = xlsread(XlsFilenamesCellArray{Index});
end


 MORE:


 ? How to modify xlsread to get a step-by-step updated flag from loading process
 ? How can I make waitbar in MATLAB modal
 ? Get waitbar value in Matlab
 ? waitbar matlab before start a standalone script
 ? matlab progress bar not depanding on time
 ? JavaFX ProgressBar/ProgressIndicator: listen for change from multiple Sliders
 ? JavaFX ProgressBar/ProgressIndicator: listen for change from multiple Sliders
 ? JavaFX ProgressBar/ProgressIndicator: listen for change from multiple Sliders
 ? JavaFX ProgressBar: how to add an animation?
 ? JavaFX ProgressBar problems