how to get value from pop-up menu in GUIDE without using automatic generate m.file
    조회 수: 2 (최근 30일)
  
       이전 댓글 표시
    
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
댓글 수: 0
답변 (1개)
  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.
댓글 수: 0
참고 항목
카테고리
				Help Center 및 File Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

