clc;clear all;close all;
[fname,pname]=uiputfile('*.xlsx','保存文件');
if fname == 0 %按取消键返回
return
end
str_name = fullfile(pname,fname); %获得完整路径名
%% 后台复制copyfile
status=copyfile('model.xlsx',str_name,'f')
filepath=uigetdir({},'choose your filepath');%選擇數據所在位置
getfilename=ls(strcat(filepath,'\*.xls'));%獲得xls文件名稱
filename = cellstr(getfilename);%轉換為cell格式
waitingwriteLFR=[]%新建空白矩陣
waitingwriteRFR=[]%新建空白矩陣
waitingwriteLI=[]%新建空白矩陣
waitingwriteRI=[]%新建空白矩陣
waitingwriteB=[]%新建空白矩陣
waitingwriteM=[]%新建空白矩陣
for i=1: length(filename)
[dataFR,wordFR,totalFR]=xlsread(strcat(filepath,'\',filename{i}),'耳机')%抓取耳机sheet中數據
[dataM,wordM,totalM]=xlsread(strcat(filepath,'\',filename{i}),'咪头')
ind=findstr(filename{i},'.')%從文件名中查詢.字符所在位置
result=cellstr(filename{i}(ind-4:ind-1))%根據查詢字符所在位置,輸入自己想要找到的字符位置,并存入到一個單元格中
writeLFR=[totalFR(2:2,2:4),result,totalFR(2:2,1:1),(totalFR(2:2,5:65))]%整理成自己想要的格式
writeRFR=[totalFR(3:3,2:4),result,totalFR(3:3,1:1),(totalFR(3:3,5:65))]
writeLI=[totalFR(4:4,2:4),result,totalFR(4:4,1:1),(totalFR(4:4,5:65))]
writeRI=[totalFR(5:5,2:4),result,totalFR(5:5,1:1),(totalFR(5:5,5:65))]
writeB=[totalFR(6:6,2:4),result,totalFR(6:6,1:1),(totalFR(6:6,5:65))]
writeM=[totalM(2:2,2:4),result,totalM(2:2,1:1),(totalM(2:2,5:45))]
waitingwriteLFR=[waitingwriteLFR;writeLFR]%把數據暫存,縮短運行時間
waitingwriteRFR=[waitingwriteRFR;writeRFR]
waitingwriteLI=[waitingwriteLI;writeLI]
waitingwriteRI=[waitingwriteRI;writeRI]
waitingwriteB=[waitingwriteB;writeB]
waitingwriteM=[waitingwriteM;writeM]
end
xlswrite(str_name,waitingwriteLFR,'L FR',strcat('A35',':',['BN',num2str(35+length(filename)-1)]))%保存最終運行結果
xlswrite(str_name,waitingwriteRFR,'R FR',strcat('A35',':',['BN',num2str(35+length(filename)-1)]))
xlswrite(str_name,waitingwriteLI,'L Impedance',strcat('A35',':',['BN',num2str(35+length(filename)-1)]))
xlswrite(str_name,waitingwriteRI,'R Impedance',strcat('A35',':',['BN',num2str(35+length(filename)-1)]))
xlswrite(str_name,waitingwriteB,'L&R balance',strcat('A35',':',['BN',num2str(35+length(filename)-1)]))
xlswrite(str_name,waitingwriteM,'Microphone FR',strcat('A35',':',['AT',num2str(35+length(filename)-1)]))