Re: [討論] GUI設計問題已回收

看板MATLAB作者 (可憐人)時間14年前 (2011/06/16 23:35), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/2 (看更多)
function ex18_1(arg) global h_pop h_chk x y; if nargin==0 arg='ini'; end switch arg case 'ini' figure('Position',[80 80 280 220],'Menubar','none'); axes('Position',[0.1 0.25 0.8 0.65]); % 建立繪圖區元件 h_chk=uicontrol('Style','checkbox','String','Grid',... 'position',[20 10 50 20],'callback','ex18_1(''gd'')'); h_pop=uicontrol('Style','popupmenu','String','20|40|60',... 'position',[80 10 50 20],'callback','ex18_1(''pts'')'); n=20; x=linspace(0,6,n); % 建立一個具有n個元素的向量x y=sin(3*x)./(x+1); plot(x,y,'-',x,y,'.r'); case 'pts' switch get(h_pop,'value') case 1 n=20; case 2 n=40; case 3 n=60; end %--------------這裡你更新了n, 但是沒依照n來重新畫圖---------------------- x=linspace(0,6,n); % 建立一個具有n個元素的向量x y=sin(3*x)./(x+1); %------------------------------------------------------------------------ plot(x,y,'-',x,y,'.r') case 'gd' if get(h_chk,'Value')==1 % 如果核取方塊有被選取,則繪上網格線 grid on hold on else %--------------這行多餘-------------------------------------------------- % get(h_chk,'Value')==0; %------------------------------------------------------------------------ grid off end end -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.134.181.185 ※ 編輯: mp19990920 來自: 220.134.181.185 (06/16 23:36)

06/19 21:41, , 1F
多謝~小弟知道問題所在了
06/19 21:41, 1F
文章代碼(AID): #1D-YAxOJ (MATLAB)
文章代碼(AID): #1D-YAxOJ (MATLAB)