[討論] 程式稍微錯誤已回收

看板MATLAB作者 (小傑〃)時間16年前 (2010/04/30 11:30), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串1/1
程式大致上打好了 可是在呈現SIN圖形時的 20個點 40個點 沒問題 可是選擇COS徒刑十 20個點 40個點時會跑回SIN圖形 該改哪邊呢 function EX1(arg) global n if nargin==0 arg='init' end switch(arg) case 'init' figure('position',[80 80 400 400],'menubar','none','name','Quiz 1'); ha=axes('position',[0.1 0.2 0.8 0.65]); h1=uicontrol('style','listbox','string','sin(x)|cos(x)','position',[40 40 60 20]); h2=uicontrol('style','popupmenu','string','20|40','position',[120 40 60 20]); h3=uicontrol('style','radio','string','grid','position',[240 40 60 20]); h4=uicontrol('style','pushbutton','string','close','position',[320 40 60 20]); set(h1,'callback','EX1 plot1'); set(h2,'callback','EX1 plot2'); set(h3,'callback','EX1 grid'); set(h4,'callback','EX1 close'); set(h1,'tag','txt1'); set(h2,'tag','txt2'); set(h3,'tag','txt3'); set(h4,'tag','txt4'); case 'plot1' h1=findobj(0,'tag','txt1') x=linspace(0,2*pi,n); switch get(h1,'value'); case 1 y=sin(x); plot(x,y,'.r',x,y); case 2 y=cos(x); plot(x,y,'.r',x,y); end case 'plot2' h2=findobj(0,'tag','txt2') switch get(h2,'value'); case 1 n=20; case 2 n=40; end x=linspace(0,6,n); y=sin(x); plot(x,y,'-',x,y,'.r') h3=findobj(0,'tag','txt3') if get(h3,'value')==1 grid on end case 'grid' grid case 'close' close end end 感謝!! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 120.124.128.56 ※ 編輯: jl851037 來自: 120.124.104.78 (04/30 12:16)

05/01 14:48, , 1F
救救我呀 >"<
05/01 14:48, 1F
文章代碼(AID): #1BsaxbCM (MATLAB)
文章代碼(AID): #1BsaxbCM (MATLAB)