📄 matlab实用程序百例2.txt
字号:
'tag','e3',...
'style','edit',...
'horizontal','right',...
'backgroundcolor',[1 1 1],...
'fontsize',12,...
'position',[140 80 30 20],...
'string',num2str(now(3)));
t3=uicontrol('parent',h0,...
'units','points',...
'tag','t3',...
'style','text',...
'string','日',...
'backgroundcolor',[0.75 0.75 0.75],...
'fontsize',14,...
'position',[175 80 20 20]);
e4=uicontrol('parent',h0,...
'units','points',...
'tag','e4',...
'style','edit',...
'backgroundcolor',[1 1 1],...
'horizontal','right',...
'fontsize',12,...
'position',[20 30 100 20],...
'string',[num2str(now(4)),':',num2str(now(5)),':',num2str(now(6))]);
b1=uicontrol('parent',h0,...
'units','points',...
'tag','b1',...
'style','pushbutton',...
'backgroundcolor',[0.75 0.75 0.75],...
'string','关闭',...
'fontsize',12,...
'position',[150 30 50 20],...
'callback',[...
'k=1;,',...
'close']);
k=0;
while find(get(0,'children'))==h0
now1=fix(clock)
set(e1,'string',num2str(now1(1)));
set(e2,'string',num2str(now1(2)));
set(e3,'string',num2str(now1(3)));
set(e4,'string',[num2str(now1(4)),':',num2str(now1(5)),':',num2str(now1(6))]);
pause(1)
if k==1
break
end
end
实例65:时间计算器
h0=figure('toolbar','none',...
'position',[200 150 300 250],...
'name','实例65');
huidiao=[...
'k=0;,',...
'fyear=str2num(get(e1,''string''));,',...
'fmonth=str2num(get(e2,''string''));,',...
'fday=str2num(get(e3,''string''));,',...
'syear=str2num(get(e4,''string''));,',...
'smonth=str2num(get(e5,''string''));,',...
'sday=str2num(get(e6,''string''));,',...
'month=[0 31 28 31 30 31 30 31 31 30 31 30 31];,',...
'k=fix(fyear/4);,',...
'if rem(fyear,4)==0,',...
'month(3)=29;,',...
'else,',...
'k=k+1;,',...
'month(3)=28;,',...
'end,',...
'sum=0;,',...
'for i=1:fmonth,',...
'sum=sum+month(i);,',...
'end,',...
'fdday=fyear*365+sum+fday+k;,',...
'l=fix(syear/4);,',...
'if rem(syear,4)==0,',...
'month(3)=29;,',...
'else,',...
'l=l+1;,',...
'month(3)=28;,',...
'end,',...
'ssum=0;,',...
'for i=1:smonth,',...
'ssum=ssum+month(i);,',...
'end,',...
'sdday=syear*365+ssum+sday+l;,',...
'dday=abs(fdday-sdday);,',...
'set(e7,''string'',[num2str(dday),''天'']);'];
t0=uicontrol('parent',h0,...
'units','points',...
'tag','t0',...
'style','text',...
'string','开始日期:',...
'horizontalalignment','right',...
'fontsize',15,...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[10 160 80 20]);
t8=uicontrol('parent',h0,...
'units','points',...
'tag','t8',...
'style','text',...
'string','结束日期:',...
'horizontalalignment','right',...
'fontsize',15,...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[115 160 80 20]);
e1=uicontrol('parent',h0,...
'units','points',...
'tag','e1',...
'style','edit',...
'horizontalalignment','right',...
'backgroundcolor',[1 1 1],...
'position',[20 130 50 20]);
t1=uicontrol('parent',h0,...
'units','points',...
'tag','t1',...
'style','text',...
'string','年',...
'horizontalalignment','left',...
'fontsize',15,...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[75 130 20 20]);
e2=uicontrol('parent',h0,...
'units','points',...
'tag','e2',...
'style','edit',...
'horizontalalignment','right',...
'backgroundcolor',[1 1 1],...
'position',[20 100 50 20]);
t2=uicontrol('parent',h0,...
'units','points',...
'tag','t2',...
'style','text',...
'string','月',...
'horizontalalignment','left',...
'fontsize',15,...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[75 100 20 20]);
e3=uicontrol('parent',h0,...
'units','points',...
'tag','e3',...
'style','edit',...
'horizontalalignment','right',...
'backgroundcolor',[1 1 1],...
'position',[20 70 50 20]);
t3=uicontrol('parent',h0,...
'units','points',...
'tag','t3',...
'style','text',...
'string','日',...
'horizontalalignment','left',...
'fontsize',15,...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[75 70 20 20]);
e4=uicontrol('parent',h0,...
'units','points',...
'tag','e4',...
'style','edit',...
'horizontalalignment','right',...
'backgroundcolor',[1 1 1],...
'position',[120 130 50 20]);
t4=uicontrol('parent',h0,...
'units','points',...
'tag','t4',...
'style','text',...
'string','年',...
'horizontalalignment','left',...
'fontsize',15,...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[175 130 20 20]);
e5=uicontrol('parent',h0,...
'units','points',...
'tag','e5',...
'style','edit',...
'horizontalalignment','right',...
'backgroundcolor',[1 1 1],...
'position',[120 100 50 20]);
t5=uicontrol('parent',h0,...
'units','points',...
'tag','t5',...
'style','text',...
'string','月',...
'horizontalalignment','left',...
'fontsize',15,...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[175 100 20 20]);
e6=uicontrol('parent',h0,...
'units','points',...
'tag','e6',...
'style','edit',...
'horizontalalignment','right',...
'backgroundcolor',[1 1 1],...
'position',[120 70 50 20]);
t6=uicontrol('parent',h0,...
'units','points',...
'tag','t6',...
'style','text',...
'string','日',...
'horizontalalignment','left',...
'fontsize',15,...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[175 70 20 20]);
b1=uicontrol('parent',h0,...
'units','points',...
'tag','b1',...
'style','pushbutton',...
'string','计算日期',...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[20 40 50 20],...
'callback',huidiao);
b2=uicontrol('parent',h0,...
'units','points',...
'tag','b2',...
'style','pushbutton',...
'string','关闭',...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[20 10 50 20],...
'callback','close');
e7=uicontrol('parent',h0,...
'units','points',...
'tag','e7',...
'style','edit',...
'horizontalalignment','right',...
'backgroundcolor',[1 1 1],...
'position',[120 10 80 20]);
t7=uicontrol('parent',h0,...
'units','points',...
'tag','t7',...
'style','text',...
'string','两个日期相差:',...
'horizontalalignment','right',...
'fontsize',15,...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[100 30 110 20]);
实例66:数字操作
h0=figure('toolbar','none',...
'position',[200 150 350 200],...
'name','实例66');
e1=uicontrol('parent',h0,...
'units','points',...
'tag','e1',...
'style','edit',...
'backgroundcolor',[1 1 1],...
'position',[20 90 80 20],...
'fontsize',12,...
'horizontalalignment','right');
e2=uicontrol('parent',h0,...
'units','points',...
'tag','e2',...
'style','edit',...
'backgroundcolor',[1 1 1],...
'position',[160 90 80 20],...
'fontsize',12,...
'horizontalalignment','right');
t1=uicontrol('parent',h0,...
'units','points',...
'tag','t1',...
'style','text',...
'string','初始数值(十进制):',...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[15 110 90 20],...
'fontsize',12,...
'horizontalalignment','left');
t2=uicontrol('parent',h0,...
'units','points',...
'tag','t2',...
'style','text',...
'string','转换结果:',...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[155 110 90 20],...
'fontsize',12,...
'horizontalalignment','left');
b1=uicontrol('parent',h0,...
'units','points',...
'tag','b1',...
'style','pushbutton',...
'string','二进制',...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[30 50 50 20],...
'callback',[...
'k=get(e1,''string'');,',...
'k2=str2num(k);,',...
'bk=dec2bin(k2);,',...
'set(e2,''string'',num2str(bk));']);
b2=uicontrol('parent',h0,...
'units','points',...
'tag','b2',...
'style','pushbutton',...
'string','清除',...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[170 50 50 20],...
'callback',[...
'set(e1,''string'','''');,',...
'set(e2,''string'','''');']);
b3=uicontrol('parent',h0,...
'units','points',...
'tag','b3',...
'style','pushbutton',...
'string','十六进制',...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[30 15 50 20],...
'callback',[...
'k=get(e1,''string'');,',...
'k3=str2num(k);,',...
'hk=dec2hex(k3);,',...
'set(e2,''string'',num2str(hk));']);
b4=uicontrol('parent',h0,...
'units','points',...
'tag','b4',...
'style','pushbutton',...
'string','关闭',...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[170 15 50 20],...
'callback','close');
实例67:图像的块操作
h0=figure('toolbar','none',...
'position',[198 56 350 468],...
'name','实例67');
h1=axes('parent',h0,...
'position',[0.2 0.45 0.6 0.5],...
'visible','off');
I=imread('tire.tif');
imshow(I)
b1=uicontrol('parent',h0,...
'units','points',...
'tag','b1',...
'backgroundcolor',[0.75 0.75 0.75],...
'style','pushbutton',...
'string','边沿操作',...
'position',[30 100 50 20],...
'callback',[...
'cla,',...
'I=imread(''tire.tif'');,',...
'f=inline(''max(x(:))'');,',...
'I2=nlfilter(I,[2 2],f);,',...
'imshow(I2)']);
b2=uicontrol('parent',h0,...
'units','points',...
'tag','b2',...
'backgroundcolor',[0.75 0.75 0.75],...
'style','pushbutton',...
'string','显示块操作',...
'position',[100 100 50 20],...
'callback',[...
'cla,',...
'I=imread(''tire.tif'');,',...
'f=inline(''uint8(round(mean2(x)*ones(size(x))))'');,',...
'I2=blkproc(I,[6 6],f);,',...
'imshow(I2)']);
b3=uicontrol('parent',h0,...
'units','points',...
'tag','b3',...
'backgroundcolor',[0.75 0.75 0.75],...
'style','pushbutton',...
'string','交叠块操作',...
'position',[170 100 50 20],...
'callback',[...
'cla,',...
'I=imread(''tire.tif'');,',...
'f=inline(''uint8(round(mean2(x)*ones(size(x))))'');,',...
'I2=blkproc(I,[6 6],[3 3],f);,',...
'imshow(I2)']);
b4=uicontrol('parent',h0,...
'units','points',...
'tag','b4',...
'backgroundcolor',[0.75 0.75 0.75],...
'style','pushbutton',...
'string','关闭',...
'fontsize',14,...
'position',[90 50 70 30],...
'callback','close');
实例68:图形的过滤操作
h0=figure('toolbar','none',...
'position',[198 56 350 468],...
'name','过滤操作');
h1=axes('parent',h0,...
'position',[0.3 0.45 0.5 0.5],...
'visible','off');
I=imread('blood1.tif');
imshow(I)
b1=uicontrol('parent',h0,...
'units','points',...
'tag','b1',...
'style','pushbutton',...
'backgroundcolor',[0.75 0.75 0.75],...
'string','均平过滤',...
'position',[50 120 50 20],...
'callback',[...
'cla,',...
'I=imread(''blood1.tif'');,',...
'h=fspecial(''average'',6);,',...
'I2=uint8(round(filter2(h,I)));,',...
'imshow(I2)']);
b2=uicontrol('parent',h0,...
'units','points',...
'tag','b2',...
'style','pushbutton',...
'backgroundcolor',[0.75 0.75 0.75],...
'string','Sobel过滤',...
'position',[150 120 50 20],...
'callback',[...
'cla,',...
'I=imread(''blood1.tif'');,',...
'h=fspecial(''sobel'');,',...
'I2=filter2(h,I);,',...
'imshow(I2,[])']);
b1=uicontrol('parent',h0,...
'units','points',...
'tag','b1',...
'style','pushbutton',...
'backgroundcolor',[0.75 0.75 0.75],...
'string','关闭',...
'position',[85 60 80 30],...
'callback','close');
实例69:图像的频率操作
h0=figure('toolbar','none',...
'position',[198 56 350 468],...
'name','频率操作');
h1=axes('parent',h0,...
'position',[0.3 0.45 0.5 0.5],...
'visible','off');
b=remez(10,[0 0.4 0.6 1],[1 1 0 0]);
h=ftrans2(b);
[H,W]=freqz(b,1,64,'whole');
colormap(jet(64))
plot(W/pi-1,fftshift(abs(H)))
b1=uicontrol('parent',h0,...
'units','points',...
'tag','b1',...
'backgroundcolor',[0.75 0.75 0.75],...
'style','pushbutton',...
'string','频率变换',...
'position',[30 100 50 20],...
'callback',[...
'cla,',...
'b=remez(10,[0 0.4 0.6 1]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -