Bonjour,

Voila j'ai un petit problème mais qui m'embette beaucoup
Dans mon code j'ai une fonction qui permet de calculer certains paramètres (la puissance par exemple) et je voudrais appeler ces paramètres dans une autres fonction mais je ne sais pas comment m'y prendre. Si quelqu'un pouvait m'aider se serait gentil

Voici mon code :

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
102
103
104
105
106
107
108
% --- Executes on button press in power_calculation.
function power_calculation_Callback(hObject, eventdata, handles)
% hObject    handle to power_calculation (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.loading_button_red,'BackgroundColor','red');
 
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                          CALCUL DE LA PUISSANCE                         %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 
%-------------------------------------------------------------------------%
% Chambre
%-------------------------------------------------------------------------%
 
Chambre = xlsread('C:\Documents and Settings\th\Bureau\Matlab\W000D.xlsx');
taille = size (Chambre);
 
 
% Champ Electrique %
 
for ligne=1:taille(1)
    Ex_chambre(ligne)=complex(Chambre (ligne,7),Chambre (ligne,10));
    Ey_chambre(ligne)=complex(Chambre (ligne,8),Chambre (ligne,11));
    Ez_chambre(ligne)=complex(Chambre (ligne,9),Chambre (ligne,12));
end
 
% Champ Magnétique %
 
for ligne=1:taille(1)
    Hx_chambre(ligne)=complex(Chambre (ligne,13),Chambre (ligne,16));
    Hy_chambre(ligne)=complex(Chambre (ligne,14),Chambre (ligne,17));
    Hz_chambre(ligne)=complex(Chambre (ligne,15),Chambre (ligne,18));
end
 
% Produit Vectoriel %
 
 Px_chambre = ((Ey_chambre.*Hz_chambre)-(Ez_chambre.*Hy_chambre));
 Py_chambre = ((Ez_chambre.*Hx_chambre)-(Ex_chambre.*Hz_chambre));
 Pz_chambre = ((Ex_chambre.*Hy_chambre)-(Ey_chambre.*Hx_chambre));
 
% Partie réelle %
 
 Re_x_chambre = real (Px_chambre);
 Re_y_chambre = real (Py_chambre);
 Re_z_chambre = real (Pz_chambre);
 
% norme %
 
 norme_chambre = sqrt((Re_x_chambre).^2+(Re_y_chambre).^2+(Re_z_chambre).^2);
 
%-------------------------------------------------------------------------%
% OATS
%-------------------------------------------------------------------------%
 
OATS = xlsread('C:\Documents and Settings\th\Bureau\Matlab\OATS3m.xlsx');
taille = size (OATS);
 
% Champ Electrique %
 
for ligne=1:taille(1)
    Ex_OATS(ligne)=complex(OATS (ligne,7),OATS (ligne,10));
    Ey_OATS(ligne)=complex(OATS (ligne,8),OATS (ligne,11));
    Ez_OATS(ligne)=complex(OATS (ligne,9),OATS (ligne,12));
end
 
% Champ Magnétique %
 
for ligne=1:taille(1)
    Hx_OATS(ligne)=complex(OATS (ligne,13),OATS (ligne,16));
    Hy_OATS(ligne)=complex(OATS (ligne,14),OATS (ligne,17));
    Hz_OATS(ligne)=complex(OATS (ligne,15),OATS (ligne,18));
end
 
% Produit Vectoriel %
 
 Px_OATS = ((Ey_OATS.*Hz_OATS)-(Ez_OATS.*Hy_OATS));
 Py_OATS = ((Ez_OATS.*Hx_OATS)-(Ex_OATS.*Hz_OATS));
 Pz_OATS = ((Ex_OATS.*Hy_OATS)-(Ey_OATS.*Hx_OATS));
 
% Partie réelle %
 
 Re_x_OATS = real (Px_OATS);
 Re_y_OATS = real (Py_OATS);
 Re_z_OATS = real (Pz_OATS);
 
% norme %
 
 norme_OATS = sqrt((Re_x_OATS).^2+(Re_y_OATS).^2+(Re_z_OATS).^2); 
 
%-------------------------------------------------------------------------%
% Resultat : Puissance
%-------------------------------------------------------------------------%
 
Puissance = 10*log10(norme_chambre./norme_OATS);
 
%-------------------------------------------------------------------------%
% Loading Button
%-------------------------------------------------------------------------%
 bar = waitbar(0,'Please wait...');
        for delay=1:1000,
            waitbar(delay/1000,bar)
        end
close(bar);   
 
set(handles.loading_button_green,'BackgroundColor','green');
et voici la fonction dans laquelle je voudrais appeler les résultats de la fonction power_calculation :

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
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                     ASSIGNATION PUISSANCE/COORDONNEES                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 
max_x = Chambre (taille(1),2); % le max en x est obligatoirement en dernière ligne de la matrice et en colonne 2 %
max_y = Chambre (taille(1),4); % le max en y est obligatoirement en dernière ligne de la matrice et en colonne 4 %
max_z = Chambre (taille(1),6); % le max en z est obligatoirement en dernière ligne de la matrice et en colonne 6 %
 
 
for ligne = 1:taille(1)
    for i=Chambre(ligne,1)+1:Chambre(ligne,2)
        for j=Chambre(ligne,3)+1:Chambre(ligne,4)
            for k=Chambre(ligne,5)+1:Chambre(ligne,6)
            P(j,i,k)=Puissance(ligne);
            end
        end
    end
end
 
% Creation du graphe %
 
o = findobj(gcbf,'Tag','coupe_z');
h = str2num(get(o,'String'));
if h > max_z
   set(handles.error_z,'String','Erreur : supérieur au max');
   set(handles.graphique,'Color',[0.8,0.8,0.8]);
end
graphe = P(:,:,h);
axes(handles.graphique);
set(handles.graphique,imagesc(graphe))
Merci d'avance