?? shili85.m
字號(hào):
h0=figure('toolbar','none',...
'position',[200 50 350 450],...
'name','實(shí)例85');
h1=axes('parent',h0,...
'position',[0.10 0.45 0.8 0.5],...
'visible','off');
x=0:0.2:2*pi;
y=sin(x);
plot(x,y)
b1=uicontrol('parent',h0,...
'units','points',...
'tag','b1',...
'style','pushbutton',...
'string','拉格朗日插值',...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[20 60 70 20],...
'callback',[...
'cla,',...
'strn=get(e1,''string'');,',...
'n=str2num(strn);,',...
'i=1;,',...
'x=0:0.2:2*pi;,',...
'for t=0:0.2:2*pi,',...
'y(i)=sin(t);,',...
'L(i)=lag(t,n);,',...
'i=i+1;,',...
'end,',...
'plot(x,y,''b*'',x,L,''r-''),',...
'legend(''sin(x)'',''插值函數(shù)'');,',...
'axis([0 7 -1.5 1.5])']);
b2=uicontrol('parent',h0,...
'units','points',...
'tag','b2',...
'style','pushbutton',...
'string','誤差比較',...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[170 60 70 20],...
'callback',[...
'strn=get(e1,''string'');,',...
'n=str2num(strn);,',...
'strm=get(e2,''string'');,',...
'm=str2num(strm);,',...
'dd=abs(sin(m)-lag(m,n));,',...
'msgbox([''誤差為:'',num2str(dd)],''計(jì)算結(jié)果'')']);
e1=uicontrol('parent',h0,...
'units','points',...
'tag','e1',...
'style','edit',...
'fontsize',12,...
'string','5',...
'horizontalalignment','right',...
'backgroundcolor',[1 1 1],...
'position',[50 100 40 20]);
e2=uicontrol('parent',h0,...
'units','points',...
'tag','e2',...
'style','edit',...
'fontsize',12,...
'string','1.20',...
'horizontalalignment','right',...
'backgroundcolor',[1 1 1],...
'position',[200 100 40 20]);
t1=uicontrol('parent',h0,...
'units','points',...
'tag','t1',...
'style','text',...
'string','階數(shù):',...
'fontsize',12,...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[20 100 30 20]);
t2=uicontrol('parent',h0,...
'units','points',...
'tag','t2',...
'style','text',...
'string','誤差點(diǎn):',...
'fontsize',12,...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[160 100 40 20]);
b3=uicontrol('parent',h0,...
'units','points',...
'tag','b3',...
'style','pushbutton',...
'string','關(guān)閉',...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[100 20 60 20],...
'callback','close');
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -