Limti为澳洲标准,按照当前电流的基准值计算
% Step 1: Set file path
file_path = 'C:\Users\guochangfeng\Desktop\V41\10\新建文件夹';
limit =[100 1 4 1 4 1 4 1 2 0.5 2 0.5 2 0.5 1 0.5 1 0.5 1 0.5 0.6 0.5 0.6 0.5 0.6 0.5 0.6 0.5 0.6 0.5 0.6 0.5 0.6];
% Step 2: Get the contents of all csv files under the path
csv_files = dir(fullfile(file_path, '*.csv'));
for i = 1:length(csv_files)
% Step 3: Open a csv file and select data starting from line 109
data = readmatrix(fullfile(file_path, csv_files(i).name), 'Range', 'A110');
% Step 4: Find the average of each column
column_averages = mean(data);
base = column_averages(1,16);
percent_data = column_averages/base*100;
setting = column_averages(1,1:1+32);
% Step 5: Transpose the data
transposed_data = column_averages';
% Step 6: Save to 'xlsx' file
% [~, name, ~] = fileparts(csv_files(i).name);
% writematrix(transposed_data, fullfile(file_path, [name '.xlsx']));
% writematrix(percent_data', fullfile(file_path, [name '.xlsx']));
precompare_data = percent_data(1,16:16+32);
result = precompare_data<limit;
[~, name, ~] = fileparts(csv_files(i).name);
xls_filename = fullfile(file_path, strcat(name, num2str(i), '.xlsx'));
xlswrite(xls_filename, [setting', column_averages(1,16:16+32)', percent_data(1,16:16+32)',limit',result'], 'Sheet1');
% Display completion message
disp(['Processed file ' num2str(i) ' of ' num2str(length(csv_files))]);
csv_files(i).name
result
end