フィルターのクリア

how to get value from pop-up menu in GUIDE without using automatic generate m.file

1 回表示 (過去 30 日間)
mohamed azuan wahari
mohamed azuan wahari 2016 年 5 月 21 日
回答済み: Walter Roberson 2016 年 5 月 21 日
i need code for pop-up menu in GUIDE without using automatic generate m.file
i select GUI option to generate fig file only and i create m-files for the GUI. i need to get value from list in pop-up menu for my calculate button.
this is my coding in the m-files
function twowayslab_wan
fig=openfig('twowayslab_wan.fig');
h=guihandles(fig);
set(h.btn_calc,'Callback',@Calculate);
set(h.btn_clear,'Callback',@clear);
set(h.btn_exit,'Callback','Exit');
imshow('gambar_beam2.jpg','Parent',h.axs_slab)
function Calculate(varargin)
% Assign input data to input variables
Ly=str2double(get(h.txt_Ly,'string'));
Lx=str2double(get(h.txt_Lx,'string'));
qk=str2double(get(h.txt_Qk,'string'));
gk=str2double(get(h.txt_Gk,'string'));
h_wan=str2double(get(h.txt_h,'string'));
phi=str2double(get(h.txt_phi,'string'));
fcu=str2double(get(h.txt_fcu,'string'));
% i need to get value from pop-up menu for function below
for exmaple:
case '1'
type_wan = 1
c= 20
fy=460
case '2'
type_wan = 2
c= 30
fy=250
answer=calc(Ly,Lx,qk,gk,h_wan,phi,fcu,type_wan,fy,c);
Ra=sprintf(answer);
set(h.text_answer,'string',Ra)
end

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 5 月 21 日
popvalue = get(h.NameOfPopup, 'Value');
switch popvalue
case 1:
...
end
end
However with the code you show, your "h" variable is not in scope inside Calculate. Your indentation hints you might have been wanting to use a nested routine (which would be a good idea), but you are missing the "end" that matches "function twowayslab_wan" so your Calculate function is not nested.

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by