# 在Matlab程序上循環

clc;
clear all;

F = m_F;
G = m_G;

J = m_J;
K = m_K;

N = m_N ;
O = m_O;
P = m_P;

[A,B,C,D,E] = myFun(F,G,J,K,N,O,P);

file_name = 'matrice_final.mat';
save(file_name,'A','B','C','D','E');


clc;

clear all;

set1={F,G,FF,GG,X,Y,XX,L,BH,JK};  %set of name vectors
set2={J,K,HG,UY,TR,BC,XW,IOP,ES,QA};  %set of name vectors
set3={AJ,RK,DS,TU,WS,ZZE,ZXW,TYP,ZAA,QWW};  %set of name vectors

for i=1:1:9

'set1(i)' = m_'set1(i)';
'set1(i+1)' = m_'set1(i+1)';

for j=1:1:9

'set2(j)' = m_'set2(j)';
'set2(j+1)' = m_'set2(j+1)';

for k=1:1:8

'set3(k)' = m_'set3(k)' ;
'set3(k+1)' = m_'set3(k+1)';
'set3(k+2)' = m_'set3(k+2)';

[Result1'index',Result2'index',Result3'index',Result4'index',Result5'index'] = myFun('set1(i)','set1(i+1)','set2(j)','set2(j+1)','set3(k)','set3(k+1)','set3(k+2)');  %% 9x9x8=648   index=1,2,...,648

file_name = 'matrice_final'index'.mat';
save(file_name,'Result1'index'','Result2'index'','Result3'index'','Result4'index'','Result5'index'');
clear 'set3(k)' 'set3(k+1)' 'set3(k+2)'
end
clear 'set2(j)' 'set2(j+1)'
end
clear 'set1(i)' 'set1(i+1)'
end


## 最佳答案

clc;
clear all;

set1 = {'F','G','FF','GG','X','Y','XX','L','BH','JK'};
set2 = {'J','K','HG','UY','TR','BC','XW','IOP','ES','QA'};
set3 = {'AJ','RK','DS','TU','WS','ZZE','ZXW','TYP','ZAA','QWW'};

matrices = cell(1,7);  %# An empty cell array
fileString = 'C:\Users\Documents\MATLAB\myFile\matrice_';  %# First part of
%#   file name

for i = 1:9  %# Loop over set1

matrices{1} = fileData.(['m_' set1{i}]);       %# Get matrix

matrices{2} = fileData.(['m_' set1{i+1}]);        %# Get matrix

for j = 1:9  %# Loop over set2

matrices{3} = fileData.(['m_' set2{j}]);       %# Get matrix

matrices{4} = fileData.(['m_' set2{j+1}]);        %# Get matrix

for k = 1:8  %# Loop over set3

matrices{5} = fileData.(['m_' set3{k}]);       %# Get matrix

matrices{6} = fileData.(['m_' set3{k+1}]);       %# Get matrix

matrices{7} = fileData.(['m_' set3{k+2}]);       %# Get matrix

[A,B,C,D,E] = myFun(matrices{:});  %# Pass matrices to your function

index = k+8*(j-1)+72*(i-1);        %# Combination index
fileName = ['matrice_final' int2str(index) '.mat'];  %# Save file name
save(fileName,'A','B','C','D','E');                  %# Save the data

end
end
end


data1 = load('matrice_final1.mat');  %# Load data into structure data1