我已经在我的电脑上安装了 Matlab r2010a
我需要使用函数 xlsread 从一个 *.xls 或 *.xlsx 文件中加载数据。这不是一个大挑战,问题是如何修改xlsread.m
以获得一个标志(整数),它给出了加载过程的百分比?
非常感谢。
到目前为止,我做了这个:将一个步进变量计数到一半,然后调用xlsread
这需要一点时间,在加载过程之后,49.5% 的计数器计数到最后。
不是最好的,但这就是我所拥有的
file = 'example.xls';
h = waitbar(0, ['Loading data from ' file], ...
'Name', 'Loading',...
'CreateCancelBtn',...
'setappdata(gcbf, ''canceling'', 1)');
steps = 200;
for step = 1 : steps
%# Check for Cancel button press
if getappdata(h, 'canceling')
okCancel = 1;
break
end
pause(0.01); %# Delay time for wait bar progres
if step == steps/2
[data, txt] = xlsread(file);
end
%# Process status report
waitbar(step/steps, h, sprintf(['Loading data from file... %3.2f%%'], step*100/steps));
end
set(h, 'CloseRequestFcn', 'closereq')
close(h)