folder = '/MATLAB Drive/P02'; % 将文件夹路径替换为实际文件夹的路径
fileList = dir(fullfile(folder, '*.csv')); % 获取文件夹中所有csv文件的文件名
resultMatrix = zeros(4, length(fileList)); % 用于保存结果的四行八列矩阵
for i = 1:length(fileList)
% 读取Excel文件
filePath = fullfile(fileList(i).folder, fileList(i).name);
data = readmatrix(filePath);
% 提取C10:C4105的数据
columnData = data(10:4105, 3);
% 计算均值、中值、最大值和最小值
meanVal = mean(columnData);
medianVal = median(columnData);
maxVal = max(columnData);
minVal = min(columnData);
% 将结果保存到结果矩阵中的指定位置
resultMatrix(:, i) = [meanVal; medianVal; maxVal; minVal];
end
% 将结果保存为csv文件
resultFilePath = fullfile(folder, 'result.csv');
writematrix(resultMatrix, resultFilePath);