Azzera filtri
Azzera filtri

How to have one function pop up at a time?

1 visualizzazione (ultimi 30 giorni)
Han
Han il 2 Mag 2020
I need my code to run through one thing at a time and wait until the previous one is finished. choosechoice and pianoimage pop up at the same time.
Here's my code:
%start here
% Final Project
%EGR 115-9,
%Main GUI: Run this to go through entire program.
%Starts by asking user their name and gives directions.
%Set of questions will be asked through a question dialog.
%Based on answers selected a graph will show an estimate of their knowledge
%compared to mine.
%Piano GUI will popup and user pushes keys based on random set of notes provided.
%Error message will pop up until user selects the correct keys.
%Once all correct keys were pushed the user will rate the learning
%experience.
function GUI1()
%Main Figure
f=figure();
set(f, 'MenuBar','none'); %Remove menu bar
set(f,'NumberTitle','off');
set(f,'Name', 'Note Learner'); %Change name
%Define UserData as current text in the box
set(f, 'UserData', {'"Enter Name Here"'}); %Position1: text last found in the edit box
%Set position-location, width, height
set(f,'Position', [400,200,500,300])
%Add widgets
%Edit box
editH=uicontrol('Style','edit');
%Text in the box
set(editH,'String','"Enter Name Here"');
%Express position
set(editH,'Units','Normalized');
set(editH,'Position', [0.22,0.5,0.6,0.2])
%Pushbutton
pbH=uicontrol('Style','PushButton','Units','Normalized');
set(pbH,'Position', [0.7,0.3,0.2,0.1], 'String','Enter');
set(pbH, 'Callback', {@cb_MainButtonPressed, editH, f});
end
function cb_MainButtonPressed(~, ~, edit_box, figh)%callback button
%Obtain the stored UserData
%User data field
UD=get(figh,'UserData');
%Extract string from cell array
last_string=UD{1};
%Get text from edit box
edit_text=get(edit_box, 'String');
%Display a msgbox? ONLY IF THE TWO STRINGS ARE DIFFERENT
if ~strcmp(last_string, edit_text)%<SM:IF> %<SM:NEST> %<SM:BOP>
msg=sprintf('Hi %s! Welcome to Note Learner! Click OK to begin.', edit_text);
end
%Message for messagebox
msg=sprintf('Hi %s! Welcome to Note Learner! Click OK to begin.',edit_text); %<SM:STRING>
waitfor(msgbox(msg, 'Note Learner'));
%Update the stored UserData
UD{1}=edit_text;
set(figh,'UserData',UD)
close(allchild(0));
uiwait(msgbox('Directions: Before you begin the actual Note Learner you will be asked a few questions. These questions will give us an understanding of your experience with piano. An estimate of your experience will be plotted compared to mine. I have been playing piano for 14 years. After the questions a piano will pop up. Click the correct keys based on the notes in the bottom left hand corner. Once you get all the notes correct you will get a chance to rate your overall learning experience.'));
questionsasked()
PianoImage()%<SM:PDF_RETURN>
choosechoice()
end
  1 Commento
Ajay Pattassery
Ajay Pattassery il 4 Mag 2020
Hello, Is PianoImage just an image and choosechoice() a GUI where user can enter value.Screenshot of the output of these functions helps.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Programming in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by