Bonjour

Je souhaite post-traiter des données. Pour cela j'ai coder un petit programme sous matlab qui est le suivant:

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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
clear all ;
L = 0.06 ; % m
A = 0.054 ; % m
omega_shaft = 60 ; % rpm
D = 0.065; %m
r = D/2;
h = 0.055; %m
X = [0];
PRESS=[1.01325];
TEMP=[300];
VOL = [];
w1 = waitbar(0,'Détermination des volumes');
for n = 0 : 2160
    ps = L + (A/2) * (1 - cos(pi*omega_shaft*n/(720*30))) - sqrt((L*L) - ((A*A/4)*sin(pi*omega_shaft*n/(30*720))*sin(pi*omega_shaft*n/(30*720))));
    X = [X, ps];
    vol = pi*r*r*(h-ps)*1000;%dcm^3
    VOL = [VOL vol];
    waitbar(n/2160)
end
X = X.';
VOL = VOL.';
close(w1)
w2 = waitbar(0,'Détermiantions des pressions');
for i = 2 : 9
    myfilename = sprintf('piston000%d.scl1',i);
    P = ReadFluentDataExport2(myfilename, 1, inf,4);
    p = mean(P)/1e5;
    PRESS = [PRESS p];
    waitbar(i/2160)
end
for i = 10 : 99
    myfilename = sprintf('piston00%d.scl1',i);
    P = ReadFluentDataExport2(myfilename, 1, inf,4);
    p = mean(P)/1e5;
    PRESS = [PRESS p];
    waitbar(i/2160)
end
for i = 100 : 999
    myfilename = sprintf('piston0%d.scl1',i);
    P = ReadFluentDataExport2(myfilename, 1, inf,4);
    p = mean(P)/1e5;
    PRESS = [PRESS p];
    waitbar(i/2160)
end
for i = 1000 : 2160
    myfilename = sprintf('piston%d.scl1',i);
    P = ReadFluentDataExport2(myfilename, 1, inf,4);
    p = mean(P)/1e5;
    PRESS = [PRESS p];
    waitbar(i/2160)
end
PRESS = PRESS.';
close(w2)
w3 = waitbar(0,'Détermination des températures');
for j = 2 : 9
    temp = 0;
    myfilename = sprintf('piston000%d.scl2',j);
    t = ReadFluentDataExport2(myfilename, 1, inf,4);
    temp = mean(t);
    TEMP = [TEMP temp];
    waitbar(j/2160)
end
for j = 10 : 99
    temp = 0;
    myfilename = sprintf('piston00%d.scl2',j);
    t = ReadFluentDataExport2(myfilename, 1, inf,4);
    temp = mean(t);
    TEMP = [TEMP temp];
    waitbar(j/2160)
end
for j = 100 : 999
    temp = 0;
    myfilename = sprintf('piston0%d.scl2',j);
    t = ReadFluentDataExport2(myfilename, 1, inf,4);
    temp = mean(t);
    TEMP = [TEMP temp];
    waitbar(j/2160)
end
for j = 1000 : 2160
    temp = 0;
    myfilename = sprintf('piston%d.scl2',j);
    t = ReadFluentDataExport2(myfilename, 1, inf,4);
    temp = mean(t);
    TEMP = [TEMP temp];
    waitbar(j/2160)
end
TEMP = TEMP.';
close(w3)
 
figure
plot(VOL(1:720,1),TEMP(1:720,1),VOL(720:1440,1),TEMP(720:1440,1),'--',VOL(1440:2160,1),TEMP(1440:2160,1),':')
title('(T,V)')
xlabel('Volume (dcm^3)')
ylabel('Température (K)')
legend('Cycle 1','Cycle 2','Cycle 3')
figure
plot(VOL(1:720,1),PRESS(1:720,1),VOL(720:1440,1),PRESS(720:1440,1),'--',VOL(1440:2160,1),PRESS(1440:2160,1),':')
title('(P,V)')
xlabel('Volume (dcm^3)')
ylabel('Pression absolue (Bar)')
legend('Cycle 1','Cycle 2','Cycle 3')
Le nom des fichiers ne seront pas les mêmes mais le système de numérotation ne changera pas. Pour ce cas, le nom des fichiers est "pistonXXXX". Par conséquent, je voudrais transformer ce script en fonction qui me donnera les graphes en lui donnant juste la base du nom dans ce cas "piston". Après avoir regarder comment faire, je n'ai pas trouvé.

Merci d'avance pour votre aide.

Cordialement