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 :

variables dans un tableau lisible dans workspace ou un fichier .mat


Sujet :

Interfaces Graphiques

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    110
    Détails du profil
    Informations personnelles :
    Âge : 66
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 110
    Par défaut variables dans un tableau lisible dans workspace ou un fichier .mat
    Bonjour
    voila, j'ai des variables qui sont toutes des variables venant d'un autre programme appelé "filproc". Ces variables sont passées au programme "frmExprtmarks" et elles sont sensées être enregistrées. Le problème c'est que j'ai des structures qui ne sont pas lues par le wizard du workspace, et que je n'arrive pas a les faire s'enregistrer sous une forme lisible par ce dernier. Ce que je voudrai faire c'est enregistrer les différentes variables, avec leur indice, pour que cela soit lisible : soit par le workspace , soit dans un fichier .MAT. La variable qui me semble le mieux c'est la variable "mrkInfo", qui comporte seulement pour l'instant une seule valeur (la dernière sélectionnée), mais je compte sur vous , et que je voudrait bien la voir contenir un tableau de valeurs?
    Je ne suis pas certain de m'être bien exprimé, mais je suis là pour vous donner toutes les informations nécessaires. Si vous pouviez me donner quelques indications cela serait bien.
    Voici le code du fichier frmExprtmarks.M cela se situe dans le bouton bnSave
    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
    function varargout = frmExprtmarks(varargin)
    % FRMEXPRTMARKS M-file for frmExprtmarks.fig
    %      FRMEXPRTMARKS, by itself, creates a new FRMEXPRTMARKS or raises the existing
    %      singleton*.
    %
    %      H = FRMEXPRTMARKS returns the handle to a new FRMEXPRTMARKS or the handle to
    %      the existing singleton*.
    %
    %      FRMEXPRTMARKS('CALLBACK',hObject,eventData,handles,...) calls the local
    %      function named CALLBACK in FRMEXPRTMARKS.M with the given input arguments.
    %
    %      FRMEXPRTMARKS('Property','Value',...) creates a new FRMEXPRTMARKS or raises the
    %      existing singleton*.  Starting from the left, property value pairs are
    %      applied to the GUI before frmExprtmarks_OpeningFcn gets called.  An
    %      unrecognized property name or invalid value makes property application
    %      stop.  All inputs are passed to frmExprtmarks_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 frmExprtmarks
     
    % Last Modified by GUIDE v2.5 21-Nov-2008 11:54:06
     
    % Begin initialization code - DO NOT EDIT
    gui_Singleton = 1;
    gui_State = struct('gui_Name',       mfilename, ...
                       'gui_Singleton',  gui_Singleton, ...
                       'gui_OpeningFcn', @frmExprtmarks_OpeningFcn, ...
                       'gui_OutputFcn',  @frmExprtmarks_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 frmExprtmarks is made visible.
    function frmExprtmarks_OpeningFcn(hObject, eventdata, handles, varargin)
    global copyData nLab expdMarks Nmax Nmrk
    % 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 frmExprtmarks (see VARARGIN)
    % Choose default command line output for frmExprtmarks
    handles.output = hObject;
    % Update handles structure
    guidata(hObject, handles);
    % UIWAIT makes frmExprtmarks wait for user response (see UIRESUME)
    %                     1    2             3                   4        5
     %hgx=frmExprtmarks(labs, nLab, get(handles.lbFiles,'String'),SelPlots,Nm);
     Lall=varargin{1};
     nLab=varargin{2};
     sc=varargin{1}{nLab};
     for k=1:length(Lall)
       if strcmp(sc,Lall{k}) 
          Lall(k)=[];
          break 
       end    
     end   
     set(handles.lbLabs2copy,'String',Lall);
     set(handles.lbTrials2copy,'String',varargin{3});
     s=sprintf('Export marker(s) from label %s',sc);
     set(handles.txtCopyfrom,'String',s);
     plots=varargin{4};
     Nmax=varargin{5}; %max number of marker
     copyinfo=cell(1,1);
     copyData=struct('Plot',[],'Marker',[]);
     for npl=1:length(plots)
       plud=get(plots(npl),'UserData');
       trs=get(handles.lbTrials2copy,'String');
       tr=trs{plud.nTr};
       for mi=1:length(plud.hG)
         mrud=get(plud.hG(mi),'UserData'); %marker's userdata
         s=sprintf('Trial %s: Marker ¹%d at %.2f sec.',tr,mrud(4),mrud(2));
         if isempty(copyinfo{1})   
            copyinfo{1}=s;
            copyData(1).Plot=plots(npl);
            copyData(1).Marker=plud.hG(mi);
         else 
            copyinfo{end+1}=s;
            copyData(end+1).Plot=plots(npl);
            copyData(end).Marker=plud.hG(mi);
         end    
       end    
     end
     set(handles.lbMarkers,'String',copyinfo)
     Nmrk=0; %current 'inner' number of exported markers
     lbMarkers_Callback(handles.lbMarkers, eventdata, handles)
     uicontrol(handles.lbMarkers);
     expdMarks=[]; %structure array of exported markers info
     uiwait(hObject);
    %-------------------------------------------------------------------
     %DELETING the EXPORTED MARKER clicked & information about it
    function delXM(src,evnt) %callback function for click on marker, src - the MARKER clicked
    global expdMarks hgme 
    NumMrk=get(src, 'UserData'); %MARKER number
    for im=1:length(expdMarks)
        if expdMarks(im).Numark==NumMrk
            expdMarks(im)=[];
            break;
        end
    end
    hgme(find(hgme==src))=[]; %Deleting from hgme array an item with handle=src
    if length(expdMarks)==0 %If no exported markers...
       set(findobj('Tag','bnSave'),'Enable','off') %make the button save disabled
       expdMarks=[];
    end
    delete(src);
    %------------------------------------------------------------------------- 
    function hp=drawPlot2Exp(Trial, Label, expLabel)
    global SmartData dsRaw ChansAdded monitAdded expdMarks hgme
    %expLabel - # of Label with exported marker
    if Label>=expLabel
        Label=Label+1;
    end  
    cellInd=5;
    if Label<=dsRaw(1)              %Kinematics
        ind=1; dsr=0;
    elseif Label<=(dsRaw(1)+dsRaw(2)) %EMG
        ind=2; dsr=dsRaw(1);
    elseif Label<=sum(dsRaw)          %Force plate
        ind=3; dsr=dsRaw(1)+dsRaw(2);
    else                                %Added channel
        BaseChan=find(monitAdded==Label); %Index of 'antiderivative' channel in ChansAdded array
        ind=ChansAdded(BaseChan).dtype;  %DATA type (1,2,3) of 'antiderivative' channel
        cellInd=4;
        nChan=ChansAdded(BaseChan).nNchan;
    end
      Tstart=SmartData{Trial}{7};
      T= 1/SmartData{Trial}{1}(ind); % 1/frequency= Period  
      Ttot=(length(SmartData{Trial}{4}{ind})-1)*T; % Total time
      x=Tstart:T:Ttot+Tstart;
      %Y-data for plot
      if cellInd==5
          y=SmartData{Trial}{4}{ind}(:,Label-dsr);
      else
          y=SmartData{Trial}{4}{ind}(:,nChan);
      end
     hp=line(x,y, 'Color','k','LineStyle','--');
     %draw EXPORTED marker(s) if any
     if ~isempty(expdMarks) %is there EXPORTED markers? 
      hold on
      hgme=zeros(length(expdMarks));
      ih=0;
      clr=[1, 177/255, 100/255];
      for im=1:length(expdMarks)
         if expdMarks(im).Tr==Trial && expdMarks(im).Lb==Label %is ON THIS plot EXPTD. marker(s)?
            ih=ih+1;
            ym=get(gca,'YLim');
            markers=expdMarks(im).mInfo;
            hgme(ih)=hggroup('ButtonDownFcn',@delXM);
            plot([markers(1) markers(1)],[markers(2) ym(1)], 'Color',clr, 'HitTest','off','Parent',hgme(ih));
            plot(markers(1), markers(2),'o', 'Color',clr, 'HitTest','off','Parent',hgme(ih));
            sm=sprintf('%dX',markers(3));
            text(markers(1), ym(1),sm,'Color',clr, 'HorizontalAlignment', 'center', 'HitTest','off',...
               'VerticalAlignment', 'top','Parent',hgme(ih));
            set(hgme(ih),'UserData',expdMarks(im).Numark)
         end
      end
      hgme(ih+1:end)=[];
     end 
     hold off
     %-------------------------------------------------------------------------------  
    % --- Outputs from this function are returned to the command line.
    function varargout = frmExprtmarks_OutputFcn(hObject, eventdata, handles) 
    global Nmax
    % 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)
     
    varargout{1}=Nmax; %hObject;
    %-----------------------------------------------------------------------
    % --- Executes on selection change in lbMarkers.
    function lbMarkers_Callback(hObject, eventdata, handles)
    global copyData
    % hObject    handle to lbMarkers (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Hints: contents = get(hObject,'String') returns lbMarkers contents as cell array
    %        contents{get(hObject,'Value')} returns selected item from lbMarkers
    nInf=get(hObject,'Value');
    plData=copyData(nInf).Plot;
    plot(get(plData,'XData'),get(plData,'YData'));
    hold on
    mrk=get(copyData(nInf).Marker,'UserData'); %Marker userdata
    hge = hggroup;
    ym=get(handles.axes1,'YLim');
    %MARKER
      plot([mrk(2) mrk(2)],[mrk(3) ym(2)], 'Color','r', 'HitTest','off','Parent',hge);
      plot(mrk(2), mrk(3),'or', 'HitTest','off','Parent',hge);
      text(mrk(2), ym(2),int2str(mrk(4)),'Color', 'red', 'HorizontalAlignment', 'center', 'HitTest','off',...
          'VerticalAlignment', 'bottom','Parent',hge);
    hold off
    %--------------------------------------------------------------------------
    % --- Executes during object creation, after setting all properties.
    function lbMarkers_CreateFcn(hObject, eventdata, handles)
    % hObject    handle to lbMarkers (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    empty - handles not created until after all CreateFcns called
     
    % Hint: listbox 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
    %--------------------------------------------------------------------------
    % --- Executes on selection change in lbLabs2copy.
    function lbLabs2copy_Callback(hObject, eventdata, handles)
    global nLab hp hgme
    if ishandle(hp) 
        delete(hp)
    end   
    if ishandle(hgme) 
        delete(hgme)
    end 
    hp=[]; hgme=[];
    hp=drawPlot2Exp(get(handles.lbTrials2copy,'Value'), get(hObject,'Value'), nLab);
    %-------------------------------------------------------------------------
    % --- Executes during object creation, after setting all properties.
    function lbLabs2copy_CreateFcn(hObject, eventdata, handles)
    % hObject    handle to lbLabs2copy (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    empty - handles not created until after all CreateFcns called
    % Hint: listbox 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
    %---------------------------------------------------------------------
    % --- Executes on selection change in lbTrials2copy.
    function lbTrials2copy_Callback(hObject, eventdata, handles)
    global nLab hp hgme
    if ishandle(hp) 
        delete(hp)
    end    
    if ishandle(hgme) 
        delete(hgme)
    end
    hp=[]; hgme=[];
    hp=drawPlot2Exp(get(hObject,'Value'), get(handles.lbLabs2copy,'Value'), nLab);
    %--------------------------------------------------------------------------
    % --- Executes during object creation, after setting all properties.
    function lbTrials2copy_CreateFcn(hObject, eventdata, handles)
    % hObject    handle to lbTrials2copy (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    empty - handles not created until after all CreateFcns called
     
    % Hint: listbox 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
    %-------------------------------------------------------------------------
    % --- Executes on button press in bnExport.
    function bnExport_Callback(hObject, eventdata, handles)
    global copyData hp expdMarks  hgme nLab Nmrk
    % hObject    handle to bnExport (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    if ~ishandle(hp)
        return
    end    
    cd=get(handles.lbMarkers,'Value');
    mrud=get(copyData(cd).Marker,'UserData'); %'old' marker's userdata
    x=get(hp,'XData');
    ind=getIndByXdata(x, mrud(2));
    y=get(hp,'YData');
    yM=y(ind);
    xM=x(ind);
    ym=get(handles.axes1,'YLim');
    %DRAW MARKER
    sm=sprintf('%dX',mrud(4));
    hold on
    %DRAW exported marker
      if ishandle(hgme)
        hgme(end+1)=hggroup('ButtonDownFcn',@delXM);
      else
        hgme(1)=hggroup('ButtonDownFcn',@delXM);  
      end
      clr=[1, 177/255, 100/255];
      plot([xM xM],[yM ym(1)], 'Color',clr, 'HitTest','off','Parent',hgme(end));
      plot(xM, yM,'o','Color',clr, 'HitTest','off','Parent',hgme(end));
      text(xM, ym(1),sm,'Color', clr, 'HorizontalAlignment', 'center', 'HitTest','off',...
      'VerticalAlignment', 'top','Parent',hgme(end));
     
    hold off
    %save EXPORTED marker(s) info in expdMarks structure
    Nmrk=Nmrk+1;
    set(hgme(end),'UserData',Nmrk)
    mInf=[xM yM mrud(4)]; %x,y, marker #
     
    eLb=get(handles.lbLabs2copy,'Value');
    if eLb>=nLab 
        eLb=eLb+1;
    end    
    if isempty(expdMarks)
      expdMarks.Tr=get(handles.lbTrials2copy,'Value');
      expdMarks.Lb=eLb;
      expdMarks.mInfo=mInf;
      expdMarks.Numark=Nmrk;
    else
      expdMarks(end+1).Tr=get(handles.lbTrials2copy,'Value');
      expdMarks(end).Lb=eLb;
      expdMarks(end).mInfo=mInf;
      expdMarks(end).Numark=Nmrk;
    end   
    if ~isempty(expdMarks)
        set(handles.bnSave,'Enable','on');     
    end   
    %----------------------------------------------------------------
    % --- Executes on button press in bnClose.
    function bnClose_Callback(hObject, eventdata, handles)
    % hObject    handle to bnClose (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    close
    %-----------------------------------------------------------------
    % --- Executes on button press in bnSave.
    function bnSave_Callback(hObject, eventdata, handles)
    global expdMarks Nmax  SmartData nLab SelPlots 
    % hObject    handle to bnSave (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    ls=get(handles.lbLabs2copy,'String');
    for nm=1:length(expdMarks)
      nTr=expdMarks(nm).Tr;
      if expdMarks(nm).Lb>nLab
        nL=expdMarks(nm).Lb-1;
      else
        nL=expdMarks(nm).Lb;  
      end    
      LabNam=ls(nL);
      Nmax=Nmax+1;
      mInf=expdMarks(nm).mInfo;
      mrkInfo=struct('Label',LabNam, 'XY', mInf(1:2),'nMarker',Nmax); %MARKER info 
      if size(SmartData{nTr},2)<8
         SmartData{nTr}{8}=mrkInfo; 
      else
         SmartData{nTr}{8}=[SmartData{nTr}{8} mrkInfo]; 
      end    
    end
    for nm=1:length(expdMarks)
        mrkInfo(nm)=struct('Label',LabNam(nm), 'XY', mInf(1:2)(nm),'nMarker',Nmax);
    end   
    [FilName, PathName] = uiputfile({'*.mat','MAT-files (*.mat)'});
    Nmax
    mrkInfo
    SelPlots
    expdMarks
    mInf
    SmartData
    SmartData{nTr}{8}
    save(fullfile(PathName,FilName),'mrkInfo');
    close
    %--------------------------------------------------------------
    % --- Executes when user attempts to close figure1.
    function figure1_CloseRequestFcn(hObject, eventdata, handles)
    % hObject    handle to figure1 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    % Hint: delete(hObject) closes the figure
    delete(hObject);
    Je compte sur vous pour m'aider, et si vous le voulez je peux vous envoyer tout les programmes qui rentre en ligne de compte.
    cordialement.

  2. #2
    Rédacteur/Modérateur

    Avatar de Jerome Briot
    Homme Profil pro
    Freelance mécatronique - Conseil, conception et formation
    Inscrit en
    Novembre 2006
    Messages
    20 317
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Freelance mécatronique - Conseil, conception et formation

    Informations forums :
    Inscription : Novembre 2006
    Messages : 20 317
    Par défaut
    Je ne suis pas sûr de bien comprendre... mais essaie toujours ceci :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    assignin('base','mrkInfo',mrkInfo)
    La variable mrkInfo sera "copiée" dans le WorkSpace

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    110
    Détails du profil
    Informations personnelles :
    Âge : 66
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 110
    Par défaut J'ai essayé mais rien
    Bonjour DUT et Caro-line
    J'ai essayé le code 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
    % --- Executes on button press in bnExport.
    function bnExport_Callback(hObject, eventdata, handles)
    global copyData hp expdMarks  hgme nLab Nmrk
    % hObject    handle to bnExport (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    if ~ishandle(hp)
        return
    end    
    cd=get(handles.lbMarkers,'Value');
    mrud=get(copyData(cd).Marker,'UserData'); %'old' marker's userdata
    x=get(hp,'XData');
    ind=getIndByXdata(x, mrud(2));
    y=get(hp,'YData');
    xM=x(ind);
    yM=mrud(3);
    %yM=y(ind);
    ym=get(handles.axes1,'YLim');
    %DRAW MARKER
    sm=sprintf('%dX',mrud(4));
    hold on
     
    %DRAW exported marker
      if ishandle(hgme)
        hgme(end+1)=hggroup('ButtonDownFcn',@delXM);
      else
        hgme(1)=hggroup('ButtonDownFcn',@delXM);  
      end
      clr=[1, 177/255, 100/255];
      plot([xM xM],[yM ym(1)], 'Color',clr, 'HitTest','off','Parent',hgme(end));
      plot(xM, yM,'o','Color',clr, 'HitTest','off','Parent',hgme(end));
      text(xM, ym(1),sm,'Color', clr, 'HorizontalAlignment', 'center', 'HitTest','off',...
      'VerticalAlignment', 'top','Parent',hgme(end));
     
    hold off
    %save EXPORTED marker(s) info in expdMarks structure
    Nmrk=Nmrk+1;
    set(hgme(end),'UserData',Nmrk)
    mInf=[xM yM mrud(4)] %x,y, marker #
     
    eLb=get(handles.lbLabs2copy,'Value');
    if eLb>=nLab 
        eLb=eLb+1;
    end    
    if isempty(expdMarks)
      expdMarks.Tr=get(handles.lbTrials2copy,'Value');
      expdMarks.Lb=eLb;
      expdMarks.mInfo=mInf;
      expdMarks.Numark=Nmrk;
    else
      expdMarks(end+1).Tr=get(handles.lbTrials2copy,'Value');
      expdMarks(end).Lb=eLb;
      expdMarks(end).mInfo=mInf;
      expdMarks(end).Numark=Nmrk;
    end   
    if ~isempty(expdMarks)
        set(handles.bnSave,'Enable','on');     
    end   
     
    % --- Executes on button press in bnSave.
    function bnSave_Callback(hObject, eventdata, handles)
    global expdMarks Nmax  SmartData nLab mInf
    % hObject    handle to bnSave (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    ls=get(handles.lbLabs2copy,'String');
    for nm=1:length(expdMarks)
      nTr=expdMarks(nm).Tr;
      if expdMarks(nm).Lb>nLab
        nL=expdMarks(nm).Lb-1;
      else
        nL=expdMarks(nm).Lb;  
      end    
      LabNam=ls(nL);
      Nmax=Nmax+1;
      mInf=expdMarks(nm).mInfo;
      %mInf=[xM yM mrud(4)]; %x,y, marker #
      mrkInfo= mInf
      assignin('base','mrkInfo',mrkInfo)
      %mrkInfo=struct('Label',LabNam, 'XY', mInf(1:2),'nMarker',Nmax) %MARKER info 
      if size(SmartData{nTr},2)<8
         SmartData{nTr}{8}=mrkInfo; 
      else
    %     SmartData{nTr}{8}=[SmartData{nTr}{8} mrkInfo]; 
      end    
    end
    [fName,Path]=uiputfile({'*.xls','XLS-files (*.xls)'},'Save the markers data');
    %[fName,Path]=uiputfile({'*.mat','MAT-files (*.mat)'},'Save the markers data');
    xlswrite([Path,fName],mrkInfo);
    %save ([Path, fName], 'mrkInfo');
    close
    Mais je n'arrive a enregistrer avec le bouton save que la dernière valeur de la boucle. Le code
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    assignin('base','mrkInfo',mrkInfo)
    n'enregistre aussi que la dernière valeur dans le workspace.
    Je souhaiterai enregistrer le tableau de valeur venant de la boucle du bouton save dans un fichier excel si possible.
    Merci d'avance et j'espère avoir été assez clair

  4. #4
    Expert confirmé
    Avatar de Caro-Line
    Profil pro
    Inscrit en
    Mars 2007
    Messages
    9 458
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2007
    Messages : 9 458
    Par défaut
    Oui c'est normal puisque dans ta boucle mkrInfo est écrasé à chaque fois.
    Il faurdrait l'indicer.
    A priori quelque chose comme ça :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    for nm=1:length(expdMarks)
    %...
    mrkInfo(nm)= mInf;%ou mrkInfo{nm}=mInf
    %dans la suite du code remplacer mrkInfo par mrkInfo(nm)
    end
    Le choix des parenthèses () ou des accolades {} dépend du format de mInf, les parenthèses ne fonctionneront que si mInf est un scalaire.

    Note : Tu peux enlever la ligne avec assignin, la réponse de Dut venant plutôt d'une mauvaise compréhension de ton problème.
    Cette ligne permet d'envoyer la variable mrkInfo dans le workspace MATLAB (ie elle sera accessible en ligne de commande)

  5. #5
    Expert confirmé
    Avatar de Caro-Line
    Profil pro
    Inscrit en
    Mars 2007
    Messages
    9 458
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2007
    Messages : 9 458
    Par défaut
    Je m'autocite :
    Citation Envoyé par Caro-Line Voir le message
    Le choix des parenthèses () ou des accolades {} dépend du format de mInf, les parenthèses ne fonctionneront que si mInf est un scalaire.
    Le message signale que manifestement mInf n'est pas un scalaire mais ... autre chose de taille supérieur à 1*1.
    Il te faut donc utiliser les accolades ici.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    for nm=1:length(expdMarks)
    %...
    mrkInfo{nm}=mInf
    %dans la suite du code remplacer mrkInfo par mrkInfo{nm}
    end
    !! ATTENTION !! Le xlswrite ne fonctionnera peut-être pas !
    Pour pouvoir t'aider plus il faudrait nous dire plus précisément à quoi ressemble les données dans mrkInfo.

  6. #6
    Membre confirmé
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    110
    Détails du profil
    Informations personnelles :
    Âge : 66
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 110
    Par défaut c'est encore moi mais je ne comprends pas les tableaux !
    reboujour
    je n'ai plus de message d'erreur, ce qui est déjà bien, mais par contre il refuse de me donner le résultat. Voici ce qu'il m'affiche
    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
    mInf =
     
       35.0667    0.5273    1.0000
     
     
    ind =
     
         1
     
     
    mrkInfo = 
     
        [1x3 double]
     
     
    mInf =
     
       39.9000    0.8434    2.0000
     
     
    ind =
     
         2
     
     
    mrkInfo = 
     
        [1x3 double]    [1x3 double]
     
     
    mInf =
     
       47.3833    0.5210    3.0000
     
     
    ind =
     
         3
     
     
    mrkInfo = 
     
        [1x3 double]    [1x3 double]    [1x3 double]
    si cela permet de vous éclairer, je pense que c'est un tableaux de trois valeurs scalaires mais comment les afficher ??? Dans le xlswrite il ne m'enregistre que la dernière valeur, mais vous disiez que cela était normal ! si vous pouvez trouver un moyen cela serait un grand pas pour moi !
    Merci d'avance

  7. #7
    Membre confirmé
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    110
    Détails du profil
    Informations personnelles :
    Âge : 66
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 110
    Par défaut Je n'y arrive pas je suis perdu dans les différentes parenthèse
    rebonjour, j'ai beau tout essayer dans les différentes possibilité d'indexation et parenthèse je ne trouve pas. Voici le code , et le message d'erreur que j'arrive a avoir apres avoir essayer plein de choses :
    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
    mInf =
     
       35.0667    0.5273    1.0000
     
     
    ind =
     
         1
     
    ???  In an assignment  A(I) = B, the number of elements in B and
     I must be the same.
     
    Error in ==> frmExprtmarks>bnSave_Callback at 350
      mrkInfo(nm)= mInf
     
    Error in ==> gui_mainfcn at 96
            feval(varargin{:});
     
    Error in ==> frmExprtmarks at 42
        gui_mainfcn(gui_State, varargin{:});
     
    ??? Error using ==> waitfor
    Error while evaluating uicontrol Callback
    et le 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
    % --- Executes on button press in bnSave.
    function bnSave_Callback(hObject, eventdata, handles)
    global expdMarks Nmax  SmartData nLab mInf
    % hObject    handle to bnSave (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    ls=get(handles.lbLabs2copy,'String');
    for nm=1:length(expdMarks)
      nTr=expdMarks(nm).Tr;
      if expdMarks(nm).Lb>nLab
        nL=expdMarks(nm).Lb-1;
      else
        nL=expdMarks(nm).Lb;  
      end    
      LabNam=ls(nL);
      Nmax=Nmax+1;
      mInf=expdMarks(nm).mInfo
      %mInf=[xM yM mrud(4)]; %x,y, marker #
      ind=nm
      mrkInfo(nm)= mInf
      %mrkInfo=struct('Label',LabNam, 'XY', mInf(1:2),'nMarker',Nmax) %MARKER info 
      if size(SmartData{nTr},2)<8
         SmartData{nTr}{8}=mrkInfo; 
      else
    %     SmartData{nTr}{8}=[SmartData{nTr}{8} mrkInfo]; 
      end    
    end
    [fName,Path]=uiputfile({'*.xls','XLS-files (*.xls)'},'Save the markers data');
    %[fName,Path]=uiputfile({'*.mat','MAT-files (*.mat)'},'Save the markers data');
    xlswrite([Path,fName],mrkInfo(nm));
    %save ([Path, fName], 'mrkInfo');
    close
     
    % --- Executes on button press in bnClose.
    function bnClose_Callback(hObject, eventdata, handles)
    % hObject    handle to bnClose (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    close
    ,
    Mais lorsque j'essaye d'indexer mInf=expdMarks(nm).mInfo avec nm j'ai encore un message d'erreur
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    ???  In an assignment  A(I) = B, the number of elements in B and
     I must be the same.
     
    Error in ==> frmExprtmarks>bnSave_Callback at 347
      mInf(nm)=expdMarks(nm).mInfo
     
    Error in ==> gui_mainfcn at 96
            feval(varargin{:});
     
    Error in ==> frmExprtmarks at 42
        gui_mainfcn(gui_State, varargin{:});
     
    ??? Error using ==> waitfor
    Error while evaluating uicontrol Callback
    . Si vous avez un moment pour regarder cela serait bien car j'ai a peu pres tout essayer. Je suis dessu depuis hier et je ne trouve pas , mais je sais que je ne suis pas doué et j'espère maméloirer avec votre aide .

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

Discussions similaires

  1. [WD19] Variables de type avancé Connexion dans un tableau
    Par R&B dans le forum WinDev
    Réponses: 2
    Dernier message: 23/07/2014, 16h29
  2. Réponses: 4
    Dernier message: 09/01/2011, 13h11
  3. [Tableaux] Tableau associatif dans un tableau numéroté
    Par laloupiote dans le forum Langage
    Réponses: 4
    Dernier message: 27/03/2007, 12h15
  4. [tableau]Valeur dans un tableau
    Par kisscool31 dans le forum Collection et Stream
    Réponses: 30
    Dernier message: 17/05/2005, 09h45

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