フィルターのクリア

How should the variable declared in popup menu be called in pushbutton call back function . Can anybody help me out with this? Please. Thank you Deepa

2 ビュー (過去 30 日間)
Suppose we select a value from the menu and we have to pass that to another push button how should we do it? I've tried using it like this in the popupmenu function but they are giving me wrong values on execution .
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
global salval;
switch get(handles.popupmenu1,'Value')
case 1
salval=xlsread('salval1.xlsx','sheet1');
case 2
salval=xlsread('salval2.xlsx','sheet1');
case 3
salval=xlsread('salval3.xlsx','sheet1');
case 4
salval=xlsread('salval4.xlsx','sheet1');
case 5
salval=xlsread('salval5.xlsx','sheet1');
otherwise
end
%set(handles.popupmenu1, 'UserData', myString);
%handles.salval=salval;
set(handles.popupmenu1, 'UserData');
guidata(hObject,handles);
end
and used the value in pushbutton like this: function matchval_Callback(hObject, eventdata, handles)
S = get(handles.popupmenu1, 'UserData');
I don't know if i'm right .Can anybody please help.
Thank you Deepa

回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 7 月 29 日
編集済み: Azzi Abdelmalek 2015 年 7 月 29 日
What is the aim of this?
set(handles.popupmenu1, 'UserData')
Maybe you want
set(handles.popupmenu1, 'UserData',Value)
You can also use guidata like this:
handles.Value=Value
guidata(hObject,handles);
In another function, call it:
Value=handles.Value
  2 件のコメント
Deepa AS
Deepa AS 2015 年 7 月 30 日
Thank you for your quick response sir. But that's not working. It shows no errors but the values aren't updated again.
Cyrus Smith
Cyrus Smith 2017 年 2 月 7 日
Hi, Im having the same issue, did you make it work? Thanks

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


Andrew Paulsen
Andrew Paulsen 2017 年 5 月 31 日
Is there a correct answer more clearly stated for this question? I am at the same point in my GUI. I can import data, populate the popups, retain the popup value or index, now I want to spit a structure and those indexes back to a pushbutton calling a function that will give me my end results. Any direction or applicable links would be appreciated.
Thanks.
  2 件のコメント
Stephen23
Stephen23 2017 年 5 月 31 日
編集済み: Stephen23 2017 年 5 月 31 日
Personally I find nested functions easiest, but many people use guidata. Do not use globals. Search this forum for "callback" and you will find hundreds of threads and examples. Oh, and do not use globals.

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

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by