salut,

comment je peux regrouper 2 fonctions dans un seul programme et les appeler si j'en ai besoin ?

Ll première fonction:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
 
 tic;
 load('toto.mat')
 TS=0;
compt =1;
for c= 0.1:0.1 :100
   for sigma=0.1:0.1 :150
 
SVMstruct=svmtrain(train_BA,train_BC,'kernel_function','rbf','method','smo','rbf_sigma',sigma,'boxconstraint',c);
class=svmclassify(SVMstruct,test_BA);
[nbligne,h]=size(test_BC);
resultas=class-test_BC;
nbs=0;
for i=1:1 :nbligne
if resultas(i)==0 nbs=nbs+1;
end
end
tauxs=nbs/nbligne
if tauxs>TS
   TS=tauxs;
   compt=compt+1;
   mc=c;
   msigma=sigma;
 
end
end
end
bestT=TS;
bestC=mc;
bestsigma=msigma;
nbiteration=compt;
toc
 
msigma= bestsigma;
mc = bestC;
nbi=nbiteration;
mTS=TS;
fid = fopen('smo-rbf.mat','at');
fprintf(fid,'%s','msigma =');
fprintf(fid,' %i\n',msigma);
fprintf(fid,'%s','mc =');
fprintf(fid,'%i\n',mc);
fprintf(fid,'%s','mTS =');
fprintf(fid,'%i\n',mTS);
fprintf(fid,'%s','nbi =');
fprintf(fid,' %i\n',nbi);
fprintf(fid,'%s','TE =');
fprintf(fid,'%f\n',toc);
fclose(fid)
et la deuxième:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
tic 
load('toto.mat');
[n,m]=size(test_BC);
TS=0;
for j=1:400
class=knnclassify(test_BA,train_BA,train_BC,j,'correlation');
nbs=0;
resultas=test_BC - class ;
for i=1:n
    if resultas(i,:)==0
        nbs=nbs+1;
    end
end
taux=nbs/n;
if taux >=TS
    TS=taux;
    mj=j;
end
end
bestTS=TS
bestj=mj
toc
mmj=bestj;
mTS=bestTS;
fid = fopen('kpp-correlation.mat','at');
fprintf(fid,'%s','mTS =');
fprintf(fid,'%i\n',mTS);
fprintf(fid,'%s','mmj =');
fprintf(fid,' %i\n',mmj);
fprintf(fid,'%s','TE =');
fprintf(fid,'%f\n',toc);
fclose(fid)
Merci de votre aide