现在有单独读取excel中每个表格并计算特定范围值的程序,请问怎么循环读取excel后运行我现在的程序,最终得到每个表下每个sheet的值!为了上传简便,两个表格的内容是相同的。最终结果是可以得到每个表下每个sheet的计算值,因为有很多个表,一个一个太麻烦了!

 采纳的回答

0 个投票

clc;
clear;
mean_V=[];%要求2中每sheet的均值
for m=1:150 % 文件个数
filename=[num2str(m),'.xlsx'];
sheet_num=6;%表格数
for i=1:sheet_num
[data,txt]=xlsread(filename,i);%读取表格数值和文本数据
[num,num_1]=size(data);%data数据的大小,num为行,num1为列
%要求2
CB=26*3+2;
AF=26+6;
V=[];%初始化每sheet速度空间
for j=1:num
if(data(j,CB)>=2600&&data(j,CB)<=2700)
V=[V;data(j,AF)];%当在指定范围内,将速度存放到V数组中
end
end
mean_V=[mean_V;mean(V)];%每sheet求速度均值,存储到mean_V中
disp('要求2整理完毕');
end
disp('速度均值:');
disp(mean_V);
end
加一层循环拼接文件名逐个文件处理就可以了需要提前定义个变量装结果,循环中把结果往变量中添加

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Data Import from MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!