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 :

"nested function error" GUIDE


Sujet :

Interfaces Graphiques

  1. #1
    Futur Membre du Club
    Profil pro
    Inscrit en
    Mai 2012
    Messages
    24
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Mai 2012
    Messages : 24
    Points : 7
    Points
    7
    Par défaut "nested function error" GUIDE
    Bonjour,

    Je sais que le problème a déjà été traité dans un sujet précédent mais les solutions données ne m'ont été d'aucun secours. Aujourd'hui lors de l'écriture de mon code, matlab m'a souligné toutes les fonctions de mon GUI et a affiché le message d'erreur suivant lors du lancement:
    "Function definition is misplaced or improperly nested"
    Toutes les fonctions sont désormais "unexpected matlab.."
    impossible de lancer le guide, qui ne reconnait plus aucune fonction. Quelqu'un a t-il une solution?
    PS: cela a remarché pendant 3 min avant de réafficher le même message

    EDIT: le code fait plus de 600 lignes mais je peux l'afficher si besoin est. Le problème est que même pour les fonctions du type
    function tag_CreateFcn ça bug

  2. #2
    Invité
    Invité(e)
    Par défaut
    Bonjour,

    Comme spécifié dans la FAQ, tu as pensé à
    rajouter le mot-clé end marquant la fin de toutes les fonctions contenues dans le fichier .m.
    La définition d'une fonction imbriquée ne pourra pas figurer au sein d'une instruction de contrôle. Ceci inclut les blocs if/elseif/else, switch, for, while, et try/catch.

  3. #3
    Futur Membre du Club
    Profil pro
    Inscrit en
    Mai 2012
    Messages
    24
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Mai 2012
    Messages : 24
    Points : 7
    Points
    7
    Par défaut
    effectivement le problème s'est réglé de lui même en mettant un end à la fin de chaque fonction. Je n'ai jamais eu besoin de le faire auparavant, pourquoi subitement ?
    EDIT en fait ça ne marche pas plus, que je mette un end à la fin de la fonction générale ou de chaque sous fonction

  4. #4
    Invité
    Invité(e)
    Par défaut
    Car la seule différence qui fait qu'une fonction est imbriquée est justement l'emplacement des end marquant la fin des différentes fonctions.
    Cf ce message.

    [EDIT] Qu'en est-il de la seconde partie ?

  5. #5
    Futur Membre du Club
    Profil pro
    Inscrit en
    Mai 2012
    Messages
    24
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Mai 2012
    Messages : 24
    Points : 7
    Points
    7
    Par défaut
    bon j'ai suivi la structure indiquée dans ton lien avec un end a la fin de chaque subfonction et un end pour la fonction générale
    mais ça ne marche toujours pas. Le .fig se lance sans message d'erreur mais quand je veux le manipuler il en affiche une serie

    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
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    function varargout = freelab(varargin)
    % FREELAB MATLAB code for freelab.fig
    %      FREELAB, by itself, creates a new FREELAB or raises the existing
    %      singleton*.
    %
    %      H = FREELAB returns the handle to a new FREELAB or the handle to
    %      the existing singleton*.
    %
    %      FREELAB('CALLBACK',hObject,eventData,handles,...) calls the local
    %      function named CALLBACK in FREELAB.M with the given input arguments.
    %
    %      FREELAB('Property','Value',...) creates a new FREELAB or raises the
    %      existing singleton*.  Starting from the left, property value pairs are
    %      applied to the GUI before freelab_OpeningFcn gets called.  An
    %      unrecognized property name or invalid value makes property application
    %      stop.  All inputs are passed to freelab_OpeningFcn via varargin.
    %
    %      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
    %      instance to run (singleton)".
    %
    % See also: GUIDE, GUIDATA, GUIHANDLES
    %
    % Edit the above text to modify the response to help freelab
    %
    % Last Modified by GUIDE v2.5 25-Jun-2012 15:04:48
    %
    % Begin initialization code - DO NOT EDIT
    gui_Singleton = 1;
    gui_State = struct('gui_Name',       mfilename, ...
                       'gui_Singleton',  gui_Singleton, ...
                       'gui_OpeningFcn', @freelab_OpeningFcn, ...
                       'gui_OutputFcn',  @freelab_OutputFcn, ...
                       'gui_LayoutFcn',  [] , ...
                       'gui_Callback',   []);
    if nargin && ischar(varargin{1})
        gui_State.gui_Callback = str2func(varargin{1});
    end
     
    if nargout
        [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
    else
        gui_mainfcn(gui_State, varargin{:});
    end
     
    % End initialization code - DO NOT EDIT
     
     
    % --- Executes just before freelab is made visible.
    function freelab_OpeningFcn(hObject, eventdata, handles, varargin)
    % This function has no output args, see OutputFcn.
    % hObject    handle to figure
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    % varargin   command line arguments to freelab (see VARARGIN)
     
    % Choose default command line output for freelab
    handles.output = hObject;
     
        h=handles.uipanel3;
        set( h , 'Visible' , 'off' );
        c=handles.uipanel2;
        set( c , 'Visible' , 'off' );
        b=handles.axes1;
        set( b , 'Visible' , 'off' );
        e=handles.push_pdf;
        set( e , 'Visible' , 'on' );
        f=handles.annees;
        set( f , 'Visible' , 'on' );
        set ( handles.ymax_txt , 'Visible', 'off');
        set ( handles.xmax_txt , 'Visible', 'off');
        set ( handles.ymin_txt , 'Visible', 'off');
        set ( handles.xmin_txt , 'Visible', 'off');
    % Update handles structure
     
    handles.b=0;
    handles.f=1;
    guidata(hObject, handles);
     
    % UIWAIT makes freelab wait for user response (see UIRESUME)
    % uiwait(handles.figure1);
    end
     
    % --- Outputs from this function are returned to the command line.
    function varargout = freelab_OutputFcn(hObject, eventdata, handles) 
    % varargout  cell array for returning output args (see VARARGOUT);
    % hObject    handle to figure
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Get default command line output from handles structure
    varargout{1} = handles.output;
    end
     
    % --- Executes when selected object is changed in uipanel1.
    function uipanel1_SelectionChangeFcn(hObject, eventdata, handles)
     
    if hObject == handles.psd1
        h=handles.uipanel3;
        set( h , 'Visible' , 'off' );
        c=handles.uipanel2;
        set( c , 'Visible' , 'on' );
        b=handles.axes1;
        set( b , 'Visible' , 'on' );
        set(get(handles.axes1, 'Children'), 'Visible', 'on');
        e=handles.push_pdf;
        set( e , 'Visible' , 'off' );
        f=handles.annees;
        set( f , 'Visible' , 'off' );
        set ( handles.ymax_txt , 'Visible', 'on');
        set ( handles.xmax_txt , 'Visible', 'on');
        set ( handles.ymin_txt , 'Visible', 'on');
        set ( handles.xmin_txt , 'Visible', 'on');
    elseif hObject == handles.psd2
        h=handles.uipanel3;
        set( h , 'Visible' , 'on' );
        c=handles.uipanel2;
        set( c , 'Visible' , 'off' );
        b=handles.axes1;
        set( b , 'Visible' , 'off' );
        set(get(handles.axes1, 'Children'), 'Visible', 'off');
        e=handles.push_pdf;
        set( e , 'Visible' , 'off' );
        f=handles.annees;
        set( f , 'Visible' , 'off' );
        set ( handles.ymax_txt , 'Visible', 'off');
        set ( handles.xmax_txt , 'Visible', 'off');
        set ( handles.ymin_txt , 'Visible', 'off');
        set ( handles.xmin_txt , 'Visible', 'off');
    elseif hObject == handles.pdf
        h=handles.uipanel3;
        set( h , 'Visible' , 'off' );
        c=handles.uipanel2;
        set( c , 'Visible' , 'off' );
        b=handles.axes1;
        set( b , 'Visible' , 'off' );
        e=handles.push_pdf;
        set( e , 'Visible' , 'on' );
        f=handles.annees;
        set( f , 'Visible' , 'on' );
        set ( handles.ymax_txt , 'Visible', 'off');
        set ( handles.xmax_txt , 'Visible', 'off');
        set ( handles.ymin_txt , 'Visible', 'off');
        set ( handles.xmin_txt , 'Visible', 'off');
        set(get(handles.axes1, 'Children'), 'Visible', 'off');
    end
    end
     
     
     
     
    % --- Executes on button press in sac_button.
    function sac_button_Callback(hObject, eventdata, handles)
    % hObject    handle to sac_button (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    cla(handles.axes1)
    filename2=handles.pz;
    [filename, pathname] = uigetfile('*.sac', 'Pick a SAC file');
     
    handles.sacf=filename;
    lc = str2double(get(handles.lc,'String'));
    hc = str2double(get(handles.hc,'String'));
     
    [time,data,header] = readsac(filename);
    [T,D]=psd_24H(data,time,header,hc,lc,filename2);
    %W=cut24h(data,time); % W matrice 94 colonnes 
    %Q=[];
    %for i=1:47
     %   data=W(:,2*1);
      %  time=W(:,2*i-1);
       % [T,D]=psd_1H24(data,time,header,hc,lc,Y);
        %Q=[Q D];
    %end
     
    %I=[];
    %for j=1:length(Q)
     %   I(i)=mean(Q(i,:));%moyenne par ligne
    %end
     
    handles.per1=T;
    handles.data1=D;
     
    %handles.data=Q;
    handles.b=1;
    guidata(hObject,handles)
     
    end
     
    % --- Executes on button press in pz_button.
    function pz_button_Callback(hObject, eventdata, handles)
    %handles.pz= fichier pz
    [filename2, pathname] = uigetfile('*.pz', 'Pick a PZ file');
        if isequal(filename2,0) || isequal(pathname,0)
           disp('User pressed cancel')
        else
           disp(['User selected ', fullfile(pathname, filename2)])
        end
    handles.pz=filename2;
    guidata(hObject,handles)
    end
     
    % --- Executes on button press in save_button.
    function save_button_Callback(hObject, eventdata, handles)
    % hObject    handle to save_button (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    p=handles.b
    if b==1
        D=handles.data1;
        T=handles.per1;
    elseif b==2
        D=handles.data2;
        T=handles.per2;
    elseif b==3
        D=handles.data3;
        T=handles.per3;
    elseif b==4
        D=handles.data4;
        T=handles.per4;
    end
    H=uigetdir;
    sve(D,T,H);
    end
     
    function lc_Callback(hObject, eventdata, handles) 
    % hObject    handle to lc (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Hints: get(hObject,'String') returns contents of lc as text
    %        str2double(get(hObject,'String')) returns contents of lc as a double
    end
     
     
    % --- Executes during object creation, after setting all properties.
    function lc_CreateFcn(hObject, eventdata, handles)
    % hObject    handle to lc (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    empty - handles not created until after all CreateFcns called
     
    % Hint: edit controls usually have a white background on Windows.
    %       See ISPC and COMPUTER.
    if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
        set(hObject,'BackgroundColor','white');
    end
    end
     
     
    function hc_Callback(hObject, eventdata, handles)
    % hObject    handle to hc (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Hints: get(hObject,'String') returns contents of hc as text
    %        str2double(get(hObject,'String')) returns contents of hc as a double
    end
     
     
    % --- Executes during object creation, after setting all properties.
    function hc_CreateFcn(hObject, eventdata, handles)
    % hObject    handle to hc (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    empty - handles not created until after all CreateFcns called
     
    % Hint: edit controls usually have a white background on Windows.
    %       See ISPC and COMPUTER.
    if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
        set(hObject,'BackgroundColor','white');
    end
    end
     
     
    % --- Executes on button press in pz2.
    function pz2_Callback(hObject, eventdata, handles)
    % hObject    handle to pz2 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    [pz_file, pathname, filterindex] = uigetfile('Selectionne le fichier PZ');
    handles.pz2=pz_file;
    guidata(hObject,handles)
    end
     
     
    % --- Executes on button press in sac_dir.
    function sac_dir_Callback(hObject, eventdat,handles)
    % hObject    handle to sac_dir (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    sac_dir = uigetdir('C:\Users\Thomas\Desktop', 'Selectionne le dossier contenant les fichiers sac');
    handles.sacd=sac_dir;
    guidata(hObject,handles)
    end
     
     
    % --- Executes on button press in go_button.
    function go_button_Callback(hObject, eventdata, handles)
    % hObject    handle to go_button (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    P=handles.pz2;
    S=handles.sacd;
    N = num2str(get(handles.station,'String'));
    sactobin(P,S,N)
    end
     
     
    function station_Callback(hObject, eventdata, handles)
    % hObject    handle to station (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Hints: get(hObject,'String') returns contents of station as text
    %        str2double(get(hObject,'String')) returns contents of station as a double
    end
     
     
    % --- Executes during object creation, after setting all properties.
    function station_CreateFcn(hObject, eventdata, handles)
    % hObject    handle to station (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    empty - handles not created until after all CreateFcns called
     
    % Hint: edit controls usually have a white background on Windows.
    %       See ISPC and COMPUTER.
    if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
        set(hObject,'BackgroundColor','white');
    end
    end
     
     
    % --- Executes on button press in push_pdf.
    function push_pdf_Callback(hObject, eventdata, handles)
    % hObject    handle to push_pdf (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    end
     
     
     
    function annees_Callback(hObject, eventdata, handles)
    % hObject    handle to annees (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Hints: get(hObject,'String') returns contents of annees as text
    %        str2double(get(hObject,'String')) returns contents of annees as a double
    end
     
     
    % --- Executes during object creation, after setting all properties.
    function annees_CreateFcn(hObject, eventdata, handles)
    % hObject    handle to annees (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    empty - handles not created until after all CreateFcns called
     
    % Hint: edit controls usually have a white background on Windows.
    %       See ISPC and COMPUTER.
    if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
        set(hObject,'BackgroundColor','white');
    end
    end
     
     
     
    % --- Executes on button press in bin_button.
    function bin_button_Callback(hObject, eventdata, handles)
    % hObject    handle to bin_button (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    cla(handles.axes1)
    [bin_file, pathname, filterindex] = uigetfile('*.bin','Selectionne le fichier bin');
    [D,T]=open_bin(bin_file);
     
     
    X=smooth_1d_array(D,50);
     
    handles.data2=D;
    handles.per2=T;
    handles.b=2;
    guidata(hObject,handles)
    end
     
     
    % --- Executes on button press in freqper_button.
    function freqper_button_Callback(hObject, eventdata, handles)
    % hObject    handle to freqper_button (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    B=handles.b; 
    f=handles.f;% premier affichage ==> frequence
    cla(handles.axes1)
    if B==1
        Y=handles.data;
        C=Y(:,2);
        for i=1:length(C)
            C(i)=1/C(i);
        end
     
        axes(handles.axes1)
        if f==2 % si frequence
            X=smooth_1d_array(Y(:,1),50);
            semilogx(C,X)
            axis([0.001 10 -200 -80]);
            handles.f=1;
        else %periode
            X=smooth_1d_array(Y(:,1),50);
            semilogx(C,X)
            axis([0.1 1000 -200 -80]);
            handles.f=2;
        end
        Y=[Y(:,1) C];
        handles.data=Y;
    elseif B==2
        D=handles.datab;
        F=handles.freq;
        for i=1:length(F)
            F(i)=1/F(i);
        end
        axes(handles.axes1)
        if f==2 % si frequence
            X=smooth_1d_array(D,50);
            semilogx(F,X)
            axis([0.001 10 -200 -80]);
            handles.f=1;
        else %periode
            X=smooth_1d_array(D,50);
            semilogx(F,X)
            axis([0.1 1000 -200 -80]);
            handles.f=2;
        end
        handles.datab=D;
        handles.freq=F;
    end
    guidata(hObject,handles)
     
    end
     
     
    % --- Executes on button press in HLNM_button.
    function HLNM_button_Callback(hObject, eventdata, handles)
    % hObject    handle to HLNM_button (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    axes(handles.axes1)
    hold on
    %Y=handles.data;
    H=load('HNM.dat');
    L=load('LNM.dat');
    semilogx(H(:,1),H(:,2),L(:,1),L(:,2))
    end
     
     
     
    % --- Executes on button press in psdH_button.
    function psdH_button_Callback(hObject, eventdata, handles)
    % hObject    handle to psdH_button (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    [F1, pathname, filterindex] = uigetfile('*.sac','Selectionne le fichier sac');
    [F2, pathname, filterindex] = uigetfile('*.pz','Selectionne le fichier pz');
     
    hour = str2double(get(handles.heure_edit,'String'));
    lc = str2double(get(handles.lc,'String'));
    hc = str2double(get(handles.hc,'String'));
    [T,D]=psd_1H(F1,F2,hour,hc,lc);
     
    axes(handles.axes1)
     
    H=load('HNM.dat');
    L=load('LNM.dat');
    semilogx(T,D,H(:,1),H(:,2),L(:,1),L(:,2))
    axis([0.1 1000 -200 -80]);
    handles.b=3;
    end
     
     
     
     
     
    function heure_edit_Callback(hObject, eventdata, handles)
    % hObject    handle to heure_edit (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Hints: get(hObject,'String') returns contents of heure_edit as text
    %        str2double(get(hObject,'String')) returns contents of heure_edit as a double
    end
    % --- Executes during object creation, after setting all properties.
    function heure_edit_CreateFcn(hObject, eventdata, handles)
    % hObject    handle to heure_edit (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    empty - handles not created until after all CreateFcns called
     
    % Hint: edit controls usually have a white background on Windows.
    %       See ISPC and COMPUTER.
    if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
        set(hObject,'BackgroundColor','white');
    end
    end
     
     
    % --- Executes on button press in psddir_button.
     
     
    function ymax_txt_Callback(hObject, eventdata, handles)
    % hObject    handle to ymax_txt (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Hints: get(hObject,'String') returns contents of ymax_txt as text
    %        str2double(get(hObject,'String')) returns contents of ymax_txt as a double
    end
     
    % --- Executes during object creation, after setting all properties.
    function ymax_txt_CreateFcn(hObject, eventdata, handles)
    % hObject    handle to ymax_txt (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    empty - handles not created until after all CreateFcns called
     
    % Hint: edit controls usually have a white background on Windows.
    %       See ISPC and COMPUTER.
    if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
        set(hObject,'BackgroundColor','white');
    end
    end
     
     
     
     
    function ymin_txt_Callback(hObject, eventdata, handles)
    % hObject    handle to ymin_txt (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Hints: get(hObject,'String') returns contents of ymin_txt as text
    %        str2double(get(hObject,'String')) returns contents of ymin_txt as a double
    end
     
     
    % --- Executes during object creation, after setting all properties.
    function ymin_txt_CreateFcn(hObject, eventdata, handles)
    % hObject    handle to ymin_txt (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    empty - handles not created until after all CreateFcns called
     
    % Hint: edit controls usually have a white background on Windows.
    %       See ISPC and COMPUTER.
    if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
        set(hObject,'BackgroundColor','white');
    end
    end
     
     
    function xmin_txt_Callback(hObject, eventdata, handles)
    % hObject    handle to xmin_txt (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Hints: get(hObject,'String') returns contents of xmin_txt as text
    %        str2double(get(hObject,'String')) returns contents of xmin_txt as a double
     
     
    % --- Executes during object creation, after setting all properties.
    end
     
     
    function xmin_txt_CreateFcn(hObject, eventdata, handles)
    % hObject    handle to xmin_txt (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    empty - handles not created until after all CreateFcns called
     
    % Hint: edit controls usually have a white background on Windows.
    %       See ISPC and COMPUTER.
    if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
        set(hObject,'BackgroundColor','white');
    end
    end
     
     
     
    function xmax_txt_Callback(hObject, eventdata, handles)
    % hObject    handle to xmax_txt (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Hints: get(hObject,'String') returns contents of xmax_txt as text
    %        str2double(get(hObject,'String')) returns contents of xmax_txt as a double
    end
     
     
    % --- Executes during object creation, after setting all properties.
    function xmax_txt_CreateFcn(hObject, eventdata, handles)
    % hObject    handle to xmax_txt (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    empty - handles not created until after all CreateFcns called
     
    % Hint: edit controls usually have a white background on Windows.
    %       See ISPC and COMPUTER.
    if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
        set(hObject,'BackgroundColor','white');
    end
        end
     
     
     
     
     
    % --- Executes on button press in E_rbutton.
    function E_rbutton_Callback(hObject, eventdata, handles)
    % hObject    handle to E_rbutton (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Hint: get(hObject,'Value') returns toggle state of E_rbutton
    end
     
     
    % --- Executes on button press in Z_rbutton.
    function Z_rbutton_Callback(hObject, eventdata, handles)
    % hObject    handle to Z_rbutton (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Hint: get(hObject,'Value') returns toggle state of Z_rbutton
    end
     
     
    % --- Executes on button press in N_rbutton.
    function N_rbutton_Callback(hObject, eventdata, handles)
    % hObject    handle to N_rbutton (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    end
     
    % Hint: get(hObject,'Value') returns toggle state of N_rbutton
     
    function psddir_button_Callback(hObject, eventdata, handles)
    % hObject    handle to psddir_button (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    lc = str2double(get(handles.lc,'String'));
    hc = str2double(get(handles.hc,'String'));
    pz_dir = uigetdir('C:\Users\Thomas\Desktop', 'Selectionne le dossier contenant les fichiers pz');
    [PN,PE,PZ] = name_pz(pz_dir);
    sac_dir =  uigetdir('C:\Users\Thomas\Desktop', 'Selectionne le dossier contenant les fichiers sac');
    [SN,SE,SZ]= name_sac(sac_dir);
    K=[];
    L=[];
    M=[];
    K1=[];
    L1=[];
    M1=[];
    for i=1:size(SN,1)
        [P,app]=porritt2(SN(i,:),PN,lc,hc);
        K=[K app];
    end
    for i=1:length(K)
        K1(i)=mean(K(:,i));
    end
     
     
    for i=1:size(SE,1)
        [P,app]=porritt2(SE(i,:),PE,lc,hc);
        L=[L app];
    end
    for i=1:length(L)
        L1(i)=mean(L(:,i));
    end
     
    for i=1:size(SZ,1)
        [P,app]=porritt2(SZ(i,:),PZ,lc,hc);
        M=[M app];
    end    
    for i=1:length(M)
        M1(i)=mean(M(:,i));
    end
    handles.b=4;
    end
     
     
     
    % --- Executes on button press in gopsd_button.
    function gopsd_button_Callback(hObject, eventdata, handles)
     
    p=handles.b;
    %xmin = str2double(get(handles.xmin_txt,'String'));
    %xmax = str2double(get(handles.xmax_txt,'String'));
    %ymin = str2double(get(handles.ymin_txt,'String'));
    %ymax = str2double(get(handles.ymax_txt,'String'));
    if p==1
        T=handles.per1;
        D=handles.data1;    
        axes(handles.axes1)
        semilogx(T,D)
        axis([str2double(get(handles.xmin_txt,'String')) str2double(get(handles.xmax_txt,'String')) str2double(get(handles.ymin_txt,'String')) str2double(get(handles.ymax_txt,'String'))]);
    elseif p==2
        D=handles.data2;
        T=handles.per2;
        axes(handles.axes1)
        semilogx(T,D)
        axis([str2double(get(handles.xmin_txt,'String')) str2double(get(handles.xmax_txt,'String')) str2double(get(handles.ymin_txt,'String')) str2double(get(handles.ymax_txt,'String'))]);
    elseif p==3
        D=handles.data3;
        T=handles.per3;
        axes(handles.axes1)
        semilogx(T,D)
        axis([str2double(get(handles.xmin_txt,'String')) str2double(get(handles.xmax_txt,'String')) str2double(get(handles.ymin_txt,'String')) str2double(get(handles.ymax_txt,'String'))]);
    elseif p==4
        D=handles.data3;
        T=handles.per3;
        axes(handles.axes1)
        semilogx(T,D)
        axis([str2double(get(handles.xmin_txt,'String')) str2double(get(handles.xmax_txt,'String')) str2double(get(handles.ymin_txt,'String')) str2double(get(handles.ymax_txt,'String'))]);
    end
    end
     
    end
    Avec le message d'erreur 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
    ??? Error using ==> feval
    Undefined function or method 'hc_CreateFcn' for input arguments of type 'double'.
     
    Error in ==> gui_mainfcn at 96
            feval(varargin{:});
     
    Error in ==> freelab at 42
        gui_mainfcn(gui_State, varargin{:});
     
    Error in ==> @(hObject,eventdata)freelab('hc_CreateFcn',hObject,eventdata,guidata(hObject))
     
     
    ??? Error using ==> struct2handle
    Error while evaluating uicontrol CreateFcn
     
    ??? Error using ==> feval
    Undefined function or method 'lc_CreateFcn' for input arguments of type 'double'.
     
    Error in ==> gui_mainfcn at 96
            feval(varargin{:});
     
    Error in ==> freelab at 42
        gui_mainfcn(gui_State, varargin{:});
     
    Error in ==> @(hObject,eventdata)freelab('lc_CreateFcn',hObject,eventdata,guidata(hObject))
     
     
    ??? Error using ==> struct2handle
    Error while evaluating uicontrol CreateFcn

    [EDIT] Ce que je ne pige pas ce que j'ai fais pas mal de GUI jusque la et c'est la première fois que je dois mettre des end dans les sousfonctions

  6. #6
    Invité
    Invité(e)
    Par défaut
    Ta fonction principale se termine ligne 47, et non à la fin du fichier.
    Donc le tout dernier end à déplacer à cette ligne.

    Ceci entrainait :
    Citation Envoyé par FAQ
    À moins de faire passer son handle, elle ne sera pas utilisable par une fonction extérieure.

  7. #7
    Futur Membre du Club
    Profil pro
    Inscrit en
    Mai 2012
    Messages
    24
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Mai 2012
    Messages : 24
    Points : 7
    Points
    7
    Par défaut
    ça marche merci! une idée de l'origine du problème? pourquoi d'un coup j'ai du mettre des end partout?

  8. #8
    Invité
    Invité(e)
    Par défaut
    Déjà répondu il me semble :
    Citation Envoyé par Winjerome Voir le message
    Car la seule différence qui fait qu'une fonction est imbriquée est justement l'emplacement des end marquant la fin des différentes fonctions.
    Cf ce message.
    Si tu mélanges les deux, comment MATLAB fait-il pour savoir les limites des fonctions ?

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

Discussions similaires

  1. [VB6>VB.NET] Comment coder "break on all errors"
    Par RiiiDD dans le forum VB.NET
    Réponses: 5
    Dernier message: 07/03/2006, 12h53

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