2019-06-10 11:14

# 怎么用matlab实现excel的筛选排序？

20

``````    [~,~,data] = xlsread(filename,Sheet{j});
Data = data( 2 : end, 1 : end );
Results = sortrows(Data , [ 2 1] , {'ascend' 'ascend'};
``````

``````filename = ('c:/users/44623/Documents/MATLAB/5min 室内.xlsx');

[~, Sheet, ~] = xlsfinfo(filename);
Y = char(Sheet);

for j = 1 : length(Sheet)

Data = data( 2 : end, 1 : end );
Results = sortrows(Data , [ 2 1] , {'ascend' 'ascend'};

sheet = '17 - 18';
[aa,~] = find(Temp >= 17 & Temp < 18);
xlswrite(['c:/users/44623/Documents/MATLAB/5min 室内/Temp',Y(j,:),'.xls'],[ data(1,:) ; Data(aa(1:end),:)],sheet);

sheet = '18 - 19';
[aa,~] = find(Temp >= 18 & Temp < 19);
xlswrite(['c:/users/44623/Documents/MATLAB/5min 室内/Temp',Y(j,:),'.xls'],[ data(1,:) ; Data(aa(1:end),:)],sheet);

sheet = '19 - 20';
[aa,~] = find(Temp >= 19 & Temp < 20);
xlswrite(['c:/users/44623/Documents/MATLAB/5min 室内/Temp',Y(j,:),'.xls'],[ data(1,:) ; Data(aa(1:end),:)],sheet);

sheet = '20 - 21';
[aa,~] = find(Temp >= 20 & Temp < 21);
xlswrite(['c:/users/44623/Documents/MATLAB/5min 室内/Temp',Y(j,:),'.xls'],[ data(1,:) ; Data(aa(1:end),:)],sheet);

sheet = '21 - 22';
[aa,~] = find(Temp >= 21 & Temp < 22);
xlswrite(['c:/users/44623/Documents/MATLAB/5min 室内/Temp',Y(j,:),'.xls'],[ data(1,:) ; Data(aa(1:end),:)],sheet);

sheet = '22 - 23';
[aa,~] = find(Temp >= 22 & Temp < 23);
xlswrite(['c:/users/44623/Documents/MATLAB/5min 室内/Temp',Y(j,:),'.xls'],[ data(1,:) ; Data(aa(1:end),:)],sheet);

sheet = '23 - 24';
[aa,~] = find(Temp >= 23 & Temp < 24);
xlswrite(['c:/users/44623/Documents/MATLAB/5min 室内/Temp',Y(j,:),'.xls'],[ data(1,:) ; Data(aa(1:end),:)],sheet);

sheet = '24 - 25';
[aa,~] = find(Temp >= 24 & Temp < 25);
xlswrite(['c:/users/44623/Documents/MATLAB/5min 室内/Temp',Y(j,:),'.xls'],[ data(1,:) ; Data(aa(1:end),:)],sheet);

sheet = '25 - 26';
[aa,~] = find(Temp >= 25 & Temp < 26);
xlswrite(['c:/users/44623/Documents/MATLAB/5min 室内/Temp',Y(j,:),'.xls'],[ data(1,:) ; Data(aa(1:end),:)],sheet);

sheet = '26 - 27';
[aa,~] = find(Temp >= 26 & Temp < 27);
xlswrite(['c:/users/44623/Documents/MATLAB/5min 室内/Temp',Y(j,:),'.xls'],[ data(1,:) ; Data(aa(1:end),:)],sheet);

sheet = '27 - 28';
[aa,~] = find(Temp >= 27 & Temp < 28);
xlswrite(['c:/users/44623/Documents/MATLAB/5min 室内/Temp',Y(j,:),'.xls'],[ data(1,:) ; Data(aa(1:end),:)],sheet);

sheet = '28 - 29';
[aa,~] = find(Temp >= 28 & Temp < 29);
xlswrite(['c:/users/44623/Documents/MATLAB/5min 室内/Temp',Y(j,:),'.xls'],[ data(1,:) ; Data(aa(1:end),:)],sheet);

sheet = '29 - 30';
[aa,~] = find(Temp >= 29 & Temp < 30);
xlswrite(['c:/users/44623/Documents/MATLAB/5min 室内/Temp',Y(j,:),'.xls'],[ data(1,:) ; Data(aa(1:end),:)],sheet);

sheet = '30 - 31';
[aa,~] = find(Temp >= 30 & Temp < 31);
xlswrite(['c:/users/44623/Documents/MATLAB/5min 室内/Temp',Y(j,:),'.xls'],[ data(1,:) ; Data(aa(1:end),:)],sheet);

sheet = '31 - 32';
[aa,~] = find(Temp >= 31 & Temp < 32);
xlswrite(['c:/users/44623/Documents/MATLAB/5min 室内/Temp',Y(j,:),'.xls'],[ data(1,:) ; Data(aa(1:end),:)],sheet);

sheet = '32 - 33';
[aa,~] = find(Temp >= 32 & Temp < 33);
xlswrite(['c:/users/44623/Documents/MATLAB/5min 室内/Temp',Y(j,:),'.xls'],[ data(1,:) ; Data(aa(1:end),:)],sheet);

sheet = '33 - 34';
[aa,~] = find(Temp >= 33 & Temp < 34);
xlswrite(['c:/users/44623/Documents/MATLAB/5min 室内/Temp',Y(j,:),'.xls'],[ data(1,:) ; Data(aa(1:end),:)],sheet);

sheet = '34 - 35';
[aa,~] = find(Temp >= 34 & Temp < 35);
xlswrite(['c:/users/44623/Documents/MATLAB/5min 室内/Temp',Y(j,:),'.xls'],[ data(1,:) ; Data(aa(1:end),:)],sheet);

sheet = '35 - 36';
[aa,~] = find(Temp >= 35 & Temp < 36);
xlswrite(['c:/users/44623/Documents/MATLAB/5min 室内/Temp',Y(j,:),'.xls'],[ data(1,:) ; Data(aa(1:end),:)],sheet);

end
``````

• 点赞
• 写回答
• 关注问题
• 收藏
• 复制链接分享
• 邀请回答