How to select datas from 3 pop up menu using Guide

1 view (last 30 days)
Hi everyone,
I want to create a gui using guide to plot results from experiment. I want to be able to select every participant or just one, and to select which parameter I want to plot as ordinate and as absissa. My gui would present these following functions :
- 3 pop-up menu :
one to select the person (participant) , let's say John and Sara
one to select which abscisse , let's say choice between x1 and x2
one to select which ordonnee , let's say choice between y1 and y2
- One pushbutton 'Plot' that simply plots the datas elected by the user using the pop up menus
As I am new using guide, I am not sure to deeply understand the way it works , and i get an error message i am not able to understand, here is how I proceed :
- creating the datas :
handles.y1.john= the datas y1 from John
handles.y2.john= the datas y2 from John
handles.x1.john=
handles.x2.john=
the same with sara
% initializing :
handles.current_data.participant='sara'
handles.current_data.abscissa=handles.x1.john
handles.current_data.ordinate=handles.y1.john
%% Pop up menu 1 : select participant :
str = get(hObject, 'String');
val = get(hObject,'Value');
% Set current data to the selected data set.
switch str{val};
case 'John' % User selects charline
handles.current_data.participant=['John'];
case 'Sara' % user selects tous
handles.current_data.participant=['Sara'];
end
% Save the handles structure.
guidata(hObject,handles)
%% Pop up menu 2 : select abscissa :
% Determine the selected data set.
str = get(hObject, 'String');
val = get(hObject,'Value');
% Set current data to the selected data set.
if strcmp(handles.current_data.participant,'Sara')==1
switch str{val};
case 'x1' handles.current_data.abscissa= handles.x1.sara;
case'x2' ... end
if strcmp(handles.current_data.participant,'John')==1
switch str{val};
case 'x1'
handles.current_data.abscissa= handles.x1.john;
case'x2'
...
end
%% Pop up menu 3 : select ordinate : basically the same than select abscissa
%% Pushbutton 'Plot' plot(handles.current_data.abscissa,handles.current_data.ordinate)
I just adapted the exemple using Guide
It worked perfectly before i tryed to select the participant. So i think that the problem is in the use of handles.current_data.participant as a parametre for the actions of the other functions.
I get the following error message :
Cell contents reference from a non-cell array object.
Error in gui>selectionparticipant_Callback (line 232) switch str{val};
Error in gui_mainfcn (line 95) feval(varargin{:});
Error in nouveau_gui (line 64) gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)nouveau_gui('selectionparticipant_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
selectionparitipant_callback refers to popmenu1_callback, the one to select participant
Is anyone has an idea about how to do that...
Thank you
  1 Comment
Adam
Adam on 10 Sep 2015
The simplest way to tackle these kind of errors is to use breakpoints (which can be added by just clicking in the margin) or the 'Stop on errors' option from the 'Breakpoints' menu in the Editor.
Either of these will allow you to look at what str is on the command line. Then you should easily be able to work out what correction is needed with some live command-line testing of code to find the right solution, then put it in your GUIDE file.

Sign in to comment.

Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!