Hello, I have created drop down menu using GUI, using {option 1, ......4}
each option play a sound How to go back to first option, "option 1" after the sound ends. I want be always to go back to the first option once the sound ends, or how to rest the drop down menu to the first the option at the top of the menu
value = app.PickASoundDropDown_Black_Sp.Value;
if strcmp(value, 'Click')
clear all ; close all
app.chan_Black_Sp = 0;
elseif strcmp(value, 'Browse a File')
file = uigetfile('*wav','Select Channel 2 Audio File');
end
so, I want to go back to "Click" after I have picked an audio file is done playing.

4 Kommentare

Jan
Jan am 8 Nov. 2018
What does this mean: "go back to the first option"? What is going to where?
Abdullah Andergeery
Abdullah Andergeery am 8 Nov. 2018
the drop down menu go to the first option 1 after I pick up for example option 4, I do not the app hang on option 4 and its value.
Jan
Jan am 8 Nov. 2018
Please post the code of the callback. Maybe a screenshot clarifies, what "go to the first option" means.
Abdullah Andergeery
Abdullah Andergeery am 8 Nov. 2018
here is an image so now the dropdown menu is on "click" which is give a command of make red channel = 0 if i pick for example the sound of rain then it going to play sound of rain and the drop down menu will stay on sound of rain option without going back to "click" I hope you can understand what I mean

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Guillaume
Guillaume am 8 Nov. 2018

0 Stimmen

If you're using a uidropdown in app designer, at the end of your callback, after you've emitted your sound, set the dropdown Value property to your uidropdown ItemData(1) value.
If you're using a uicontrol of style 'popupmenu', set its Value property to 1 instead.

6 Kommentare

this not working.
if true
% code
value = app.PickASoundDropDown_Black_Sp.Value;
if strcmp(value, 'Click')
clear all ; close all
app.chan_Black_Sp = 0;
elseif strcmp(value, 'Browse a File')
file = uigetfile('*wav','Select Channel 2 Audio File');
[y,Fs] = audioread(file)
value= DataItems(1);
end
I also tried
value= DataItems('Click');
Jan
Jan am 9 Nov. 2018
Bearbeitet: Jan am 9 Nov. 2018
Please explain "is not working" with details, preferably the error message.
What is "DataItems"?
Do you mean:
app.PickASoundDropDown_Black_Sp.Value = 1
?
Abdullah Andergeery
Abdullah Andergeery am 9 Nov. 2018
Bearbeitet: Abdullah Andergeery am 9 Nov. 2018
ops! I tried this
if s.IsDone
value=ItemsData(1) ;
end
Setting the variable value to whatever is never going to affect the dropdown itself. You need to tell matlab it's the dropdown value you want to change, so:
app.PickASoundDropDown_Black_Sp.Value = app.PickASoundDropDown_Black_Sp.DataItems(1);
Abdullah Andergeery
Abdullah Andergeery am 9 Nov. 2018
thank you A looot that did work, but i used "Items" rather than "DataItems". Do you what is the different between "Items" ,and "DataItems" ?
Guillaume
Guillaume am 11 Nov. 2018
DataItems is used to associate values to the drop down selection that is different from what is displayed to the user. If you've left DataItems empty, the Value property will be the Items selected, otherwise it will be the corresponding DataItems.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by