IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Interfaces Graphiques Discussion :

Problème dans fonctions imbriquées !


Sujet :

Interfaces Graphiques

  1. #1
    Membre du Club
    Inscrit en
    Février 2008
    Messages
    78
    Détails du profil
    Informations forums :
    Inscription : Février 2008
    Messages : 78
    Points : 61
    Points
    61
    Par défaut Problème dans fonctions imbriquées !
    Bonjour,
    j'ai un bouton dans mon GUI1 en cliquant dessus il va créer un GUI2 pour l'affichage des résultats voila 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
     
    function resultats_callback(hObject, eventdata, handles)
     
    % --- FIGURE -------------------------------------
    handles.figure = figure(	'Tag', 'figure', ...
    	'Units', 'characters', ...
    	'Position', [59.8 12.6923076923077 137.6 40.1538461538462], ...
    	'Name', 'resultats', ...
    	'MenuBar', 'none', ...
    	'NumberTitle', 'off', ...
    	'Color', get(0,'DefaultUicontrolBackgroundColor'));
     
    % --- AXES -------------------------------------
    handles.axes2 = axes(	'Parent', handles.figure, ...
    	'Tag', 'axes2', ...
    	'UserData', [], ...
    	'Units', 'characters', ...
    	'Position', [13.8 4.46153846153847 100.2 32.3846153846154]);
     
    % --- PUSHBUTTONS -------------------------------------
    handles.pushbutton_Tracer = uicontrol(	'Parent', handles.figure, ...
    	'Tag', 'pushbutton_Tracer', ...
    	'UserData', [], ...
    	'Style', 'pushbutton', ...
    	'Units', 'characters', ...
    	'Position', [122 7.61538461538463 13 1.69230769230769], ...
    	'String', 'Tracer', ...
    	'Callback', @pushbutton_Tracer_Callback);
     
    % --- CHECKBOXES -------------------------------------
    handles.checkbox_graph_A = uicontrol(	'Parent', handles.figure, ...
    	'Tag', 'checkbox_graph_A', ...
    	'UserData', [], ...
    	'Style', 'checkbox', ...
    	'Units', 'characters', ...
    	'Position', [120 25 15 1.76923076923077], ...
    	'String', 'Uxy Phi');
     
    handles.checkbox_graph_B = uicontrol(	'Parent', handles.figure, ...
    	'Tag', 'checkbox_graph_B', ...
    	'UserData', [], ...
    	'Style', 'checkbox', ...
    	'Units', 'characters', ...
    	'Position', [120 22 15 1.76923076923077], ...
    	'String', 'Uxz Theta');
    function pushbutton_Tracer_Callback(hObject,evendata, handles)
     
    etat_A = get(handles.checkbox_graph_A,'Value');
    etat_B = get(handles.checkbox_graph_B,'Value');
     
    if etat_A
        plot(A(:,1),A(:,2),'LineStyle','-','LineWidth',2.5,'Color','green')
        hold on
    end
     
    if etat_B
        plot(B(:,1),B(:,2),'LineStyle','-','LineWidth',2.5,'Color','red')    
    end
     
    hold off
    je ne comprend pas pourquoi il me donne ça :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    ??? Input argument "handles" is undefined.
    etat_A = get(handles.checkbox_graph_A,'Value');
     
    ??? Error while evaluating uicontrol Callback
    MATLAB 7.6 (R2008a) & Windows XP SP2

  2. #2
    Expert confirmé
    Avatar de duf42
    Homme Profil pro
    Formateur en informatique
    Inscrit en
    Novembre 2007
    Messages
    3 111
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Formateur en informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2007
    Messages : 3 111
    Points : 4 661
    Points
    4 661
    Par défaut
    Bonjour,

    Tel que tu as posté ton code, les fonctions ne sont pas imbriquées, il manque les 'end' à la fin.

    De plus lors de l'appel du bouton, la fonction ne recoit comme argument que le handles de cet objet.

    Normalement maintenant ca devrait fonctionner.

    Bonne journée,
    Duf

    Citation Envoyé par Truth Voir le message
    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
    function resultats_callback(hObject, eventdata, handles)
    
    % --- FIGURE -------------------------------------
    handles.figure = figure(	'Tag', 'figure', ...
    	'Units', 'characters', ...
    	'Position', [59.8 12.6923076923077 137.6 40.1538461538462], ...
    	'Name', 'resultats', ...
    	'MenuBar', 'none', ...
    	'NumberTitle', 'off', ...
    	'Color', get(0,'DefaultUicontrolBackgroundColor'));
    
    % --- AXES -------------------------------------
    handles.axes2 = axes(	'Parent', handles.figure, ...
    	'Tag', 'axes2', ...
    	'UserData', [], ...
    	'Units', 'characters', ...
    	'Position', [13.8 4.46153846153847 100.2 32.3846153846154]);
    
    % --- PUSHBUTTONS -------------------------------------
    handles.pushbutton_Tracer = uicontrol(	'Parent', handles.figure, ...
    	'Tag', 'pushbutton_Tracer', ...
    	'UserData', [], ...
    	'Style', 'pushbutton', ...
    	'Units', 'characters', ...
    	'Position', [122 7.61538461538463 13 1.69230769230769], ...
    	'String', 'Tracer', ...
    	'Callback', @pushbutton_Tracer_Callback);
    
    % --- CHECKBOXES -------------------------------------
    handles.checkbox_graph_A = uicontrol(	'Parent', handles.figure, ...
    	'Tag', 'checkbox_graph_A', ...
    	'UserData', [], ...
    	'Style', 'checkbox', ...
    	'Units', 'characters', ...
    	'Position', [120 25 15 1.76923076923077], ...
    	'String', 'Uxy Phi');
    
    handles.checkbox_graph_B = uicontrol(	'Parent', handles.figure, ...
    	'Tag', 'checkbox_graph_B', ...
    	'UserData', [], ...
    	'Style', 'checkbox', ...
    	'Units', 'characters', ...
    	'Position', [120 22 15 1.76923076923077], ...
    	'String', 'Uxz Theta');
    
    function pushbutton_Tracer_Callback(hObject,varargin)
    
    etat_A = get(handles.checkbox_graph_A,'Value');
    etat_B = get(handles.checkbox_graph_B,'Value');
    
    if etat_A
        plot(A(:,1),A(:,2),'LineStyle','-','LineWidth',2.5,'Color','green')
        hold on
    end
    
    if etat_B
        plot(B(:,1),B(:,2),'LineStyle','-','LineWidth',2.5,'Color','red')    
    end
    
    hold off
    
    end
    
    end
    Simulink & Embedded Coder

    Au boulot : Windows 7 , MATLAB r2016b
    A la maison : ArchLinux mais pas MATLAB

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [XL-2010] problème dans fonction lire la ligne
    Par Nathanaël. dans le forum Macros et VBA Excel
    Réponses: 9
    Dernier message: 14/01/2015, 08h11
  2. Réponses: 1
    Dernier message: 08/05/2014, 14h53
  3. [XL-2010] Problème de fonctions imbriquées (recherche V+ logique)
    Par stargate2370 dans le forum Excel
    Réponses: 4
    Dernier message: 15/11/2012, 14h25
  4. [Google Maps] Récupérer variable dans fonction imbriquée
    Par Gentletid dans le forum APIs Google
    Réponses: 4
    Dernier message: 07/04/2012, 02h47
  5. Problème dans requête imbriquée
    Par stefsas dans le forum Langage SQL
    Réponses: 8
    Dernier message: 12/03/2010, 01h40

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo