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 件のコメント

Jan
Jan 2018 年 11 月 8 日
What does this mean: "go back to the first option"? What is going to where?
Abdullah Andergeery
Abdullah Andergeery 2018 年 11 月 8 日
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 2018 年 11 月 8 日
Please post the code of the callback. Maybe a screenshot clarifies, what "go to the first option" means.
Abdullah Andergeery
Abdullah Andergeery 2018 年 11 月 8 日
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

サインインしてコメントする。

 採用された回答

Guillaume
Guillaume 2018 年 11 月 8 日

0 投票

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 件のコメント

Abdullah Andergeery
Abdullah Andergeery 2018 年 11 月 9 日
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 2018 年 11 月 9 日
編集済み: Jan 2018 年 11 月 9 日
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 2018 年 11 月 9 日
編集済み: Abdullah Andergeery 2018 年 11 月 9 日
ops! I tried this
if s.IsDone
value=ItemsData(1) ;
end
Guillaume
Guillaume 2018 年 11 月 9 日
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 2018 年 11 月 9 日
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 2018 年 11 月 11 日
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.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by