Bonjour,

Je suis nouveau sur le forum et sur matlab simulink aussi , j'ai fais une interface graphique avec le model simulink qui va avec j'arrive a retrouver les valeurs entrées sur le pannel sur le vecteur d'entrée de simulink, aussi les résultats ( sur simulink ), mais je n'arrive pas à récuperer ce vecteur de sorti sur le workspace pour pouvoir l'afficher sur le panel .

aidez-moi svp à comprends ce qui ce passe ( ou ce qui manque ).

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
109
110
111
112
113
114
115
116
117
function equation_s (ModelName)
 
ModelName = 'equation';
mainPanel = figure(1);
light_grey = [0.9 0.9 0.9];
grey = [0.8 0.8 0.8];
red = [1 0 0];
green = [0 1 0];
white = [1 1 1];
param_vector = zeros(1,3);
 
set(mainPanel, 'Name', 'Panel Name', 'Resize', 'off',...
    'units', 'pixels', 'Position', [100 100 260 300], 'color', grey);
 
 
 
%% creation des sub Panel
 
strPanel.subPanel01 =uipanel('Fontsize', 10, 'units', 'pixels', 'Position', [10 10 120 280]...
    , 'BackGroundColor', light_grey, 'Title', 'Coefficients');
 
strPanel.subPanel02 =uipanel('Fontsize', 10, 'units', 'pixels', 'Position', [130 10 120 280]...
    , 'BackGroundColor', light_grey, 'Title', 'solution(s)');
 
 
%% Def des champs de text
 
strPanel.a_txt = uicontrol('parent', strPanel.subPanel01,'fontsize',20, 'Style', 'text', 'string', ...
    'a :', 'units', 'pixels', 'Position', [10 180 40 40], 'BackGroundColor', light_grey, ...
    'Enable', 'on', 'BackGroundColor', grey);
 
strPanel.b_txt = uicontrol('parent', strPanel.subPanel01, 'fontsize',20, 'Style', 'text', 'string', ...
    'b :', 'units', 'pixels', 'Position', [10 120 40 40], 'BackGroundColor', light_grey, ...
    'Enable', 'on', 'BackGroundColor', grey);
 
strPanel.c_txt = uicontrol('parent', strPanel.subPanel01, 'fontsize',20, 'Style', 'text', 'string', ...
    'c :', 'units', 'pixels', 'Position', [10 60 40 40], 'BackGroundColor', light_grey, ...
    'Enable', 'on', 'BackGroundColor', grey);
 
strPanel.X1_txt = uicontrol('parent', strPanel.subPanel02, 'fontsize',15, 'Style', 'text', 'string', ...
    'X1 :', 'units', 'pixels', 'Position', [10 200 40 40], 'BackGroundColor', grey, ...
    'Enable', 'on', 'BackGroundColor', grey);
 
strPanel.X2_txt = uicontrol('parent', strPanel.subPanel02, 'fontsize',15, 'Style', 'text', 'string', ...
    'X2 :', 'units', 'pixels', 'Position', [10 160 40 40], 'BackGroundColor', grey, ...
    'Enable', 'on', 'BackGroundColor', grey);
 
strPanel.X0_txt = uicontrol('parent', strPanel.subPanel02, 'fontsize',15, 'Style', 'text', 'string', ...
    'X0 :', 'units', 'pixels', 'Position', [10 120 40 40], 'BackGroundColor', grey, ...
    'Enable', 'on', 'BackGroundColor', grey);
 
strPanel.Delta_txt = uicontrol('parent', strPanel.subPanel02, 'fontsize',13, 'Style', 'text', 'string', ...
    'Delta :', 'units', 'pixels', 'Position', [10 50 60 40], 'BackGroundColor', grey, ...
    'Enable', 'on', 'BackGroundColor', grey);
 
%% Les edits
 
strPanel.a = uicontrol('Parent', strPanel.subPanel01, 'Style', 'Edit', 'units',...
    'pixels', 'Position', [60 180 40 40], 'Enable', 'on', 'BackGroundColor', white, ...
    'Callback', @a_callback);
 
strPanel.b = uicontrol('Parent', strPanel.subPanel01, 'Style', 'Edit', 'units',...
    'pixels', 'Position', [60 120 40 40], 'Enable', 'on', 'BackGroundColor', white, ...
    'Callback', @a_callback);
 
strPanel.c = uicontrol('Parent', strPanel.subPanel01, 'Style', 'Edit', 'units',...
    'pixels', 'Position', [60 60 40 40], 'Enable', 'on', 'BackGroundColor', white, ...
    'Callback', @a_callback);
 
strPanel.X1 = uicontrol('Parent', strPanel.subPanel02, 'Style', 'Edit', 'units',...
    'pixels', 'Position', [60 200 40 40], 'Enable', 'off','string',0, 'BackGroundColor', white );
 
strPanel.X2 = uicontrol('Parent', strPanel.subPanel02, 'Style', 'Edit', 'units',...
    'pixels', 'Position', [60 160 40 40], 'Enable', 'off','string',0, 'BackGroundColor', white );
 
strPanel.X0 = uicontrol('Parent', strPanel.subPanel02, 'Style', 'Edit', 'units',...
    'pixels', 'Position', [60 120 40 40], 'Enable', 'off','string',0, 'BackGroundColor', white );
 
strPanel.Delta = uicontrol('Parent', strPanel.subPanel02, 'Style', 'Edit', 'units',...
    'pixels', 'Position', [60 50 40 40], 'Enable', 'off', 'BackGroundColor', white );
 
%% Workspace assignement
 
assignin('base','strPanel',strPanel);
assignin ('base', 'param_vector' , param_vector);
 
%% CallBACKS
 
    function a_callback(hObject,~)
 
        param_vector(1,1) = str2double(get(strPanel.a,'String'));
        param_vector(1,2) = str2double(get(strPanel.b,'String'));
        param_vector(1,3) = str2double(get(strPanel.c,'String'));
 
        assignin('base','param_vector', param_vector);
        set_param([ModelName '/param_vector'],'value', 'param_vector');
 
    end
 
        delta = get_param([ModelName '/sol_vector'],'value');
        delta = delta(1,4);         %%!!!!
        if delta == 0
            set(strPanel.X1, 'backGroundColor', red);set(strPanel.X2, 'backGroundColor', red);set(strPanel.X0, 'backGroundColor', green);
        end
        if delta > 0
            set(strPanel.X1, 'backGroundColor', green);set(strPanel.X2, 'backGroundColor', green);set(strPanel.X0, 'backGroundColor', red);
        end
        if delta < 0
            set(strPanel.X1, 'backGroundColor', red);set(strPanel.X2, 'backGroundColor', red);set(strPanel.X0, 'backGroundColor', red);
        end
 
        t = get_param([ModelName '/sol_vector'],'RunTimeObject');
        set(strPanel.X1,'string',num2str(t.InputPort(1).Data));
        set(strPanel.X2,'string',num2str(t.InputPort(1).Data));
        set(strPanel.X0,'string',num2str(t.InputPort(1).Data));
 
end
Nom : Capture.PNG
Affichages : 273
Taille : 49,2 Ko




Merci