MATLAB: How do I Assign Push Buttons to Values so that I can Track the Data??
이전 댓글 표시
Hello,
For clarity, I will explain my project:
I need to create a UI where participants can listen to two versions of a speech shaped noise (2 .wav files) and choose which one they think sounds the best. I then need to collect the data on the user responses.
My progress:
I used GUIDE to create an interface with two push buttons that is presented AFTER listening to the sounds. Here is the code for one of the .m files I'm using:
function varargout = simple_gui(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @simple_gui_OpeningFcn, ...
'gui_OutputFcn', @simple_gui_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{:});
function simple_gui_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = simple_gui_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
handles.output = hObject;
function pushbutton1_Callback(hObject, eventdata, handles)
function pushbutton3_Callback(hObject, eventdata, handles)
Where I need help:
I am having trouble assigning both push buttons as different values (like 1 and 2) and have the data represented in a clean way. If I could plot them on a bar graph, that would be an added plus.
Thanks!
채택된 답변
추가 답변 (1개)
Emeka Anekwe
2015년 8월 14일
댓글 수: 1
Joe
2015년 8월 16일
So is the main issue the "flow control" of the GUI, i.e. how to tell when you've moved from one sound to the next, and one user to the next? I'm going to assume that's the case, correct me otherwise.
- To handle sound advancement, your "play sound" button can track an index of which sound to play; it can be advanced each time the button is pressed. This will also index the rows of your results matrix. Every time the GUI moves to the next user, reset the sound index.
- I would add a "next user" button the GUI as well -- you could have the "play sound" button perform that function if desired -- and add a corresponding "user index" as an object property to keep track of the column index on users.
This might also be a good time to make use of a structure array , especially if there are other user data you want to keep track of.
Finally, always overestimate the ability of your users to screw up your GUI, especially one that relies on careful flow control. I'd recommend you make heavy use of the "enable" feature to turn off buttons as necessary - for example, disable the "voting" buttons until a sound has finished playing. The pre-2014b call for that is
set(button, 'enable', 'off');
or
set(button, 'enable', 'on');
I think this syntax works in new versions as well but there is also a more OOP-like interface that will do the same thing; I haven't gotten familiar with it.
Hope this helps.
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!