From: lebland on
I do not know how to combine the indices with the characters, Could you help me to make this program possible:
set1, set2 and Set3 contain the names of vectors that already exist. The interest for me to use 3 "for loops" is to avoid rewriting the program for each combination of 7 vectors (2 from set1, 2 from set2, and 3 from Set3)

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

load('C:\Users\Documents\MATLAB\myFile\matrice_'set1(i)'.mat');
load('C:\Users\Documents\MATLAB\myFile\matrice_'set1(i+1)'.mat');

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

for j=1:1:9

load('C:\Users\Documents\MATLAB\myFile\matrice_'set2(j)'.mat');
load('C:\Users\Documents\MATLAB\myFile\matrice_'set2(j+1)'.mat');

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

for k=1:1:8

load('C:\Users\Documents\MATLAB\myFile\matrice_'set3(k)'.mat');
load('C:\Users\Documents\MATLAB\myFile\matrice_'set3(k+1)'.mat');
load('C:\Users\Documents\MATLAB\myFile\matrice_'set3(k+2)'.mat');

'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
From: vortse a on
1st: You must learn to concatenate strings with variables. All of the following commands:
load('C:\Users\Documents\MATLAB\myFile\matrice_'set1(i)'.mat');
can be done as such:
>>filename=['C:\Users\Documents\MATLAB\myFile\matrice_' set1(i) '.mat'];
>>load(filename);
If your variable is not a string but a number, use num2str(set1(i))

2nd: Check out the eval command (doc eval). It lets you run commands where variable names are given with a string. F.E. the command:
clear 'set3(k)' 'set3(k+1)' 'set3(k+2)'
can be done like this:
>>commandname=['clear ' set3(k) ' ' set3(k+1) ' ' set3(k+2)];
>>eval(commadname);