1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
| clc;clear;close all;
h0=figure('toolbar','none',... 'position',[210 50 360 450]); h1=axes('parent',h0,... 'position',[0.10 0.45 0.8 0.5],... 'visible','on');
x=-1*pi:0.05:pi; y=sin(x); plot(x,y,"r") axis([-4 4 -2 2])
Button1=uicontrol('parent',h0,... 'units','points',... 'style','pushbutton',... 'string','Button1',... 'fontsize',15,... 'backgroundcolor',[0.8 0.8 0.8],... 'position',[28 100 80 20],... 'callback',[... 'strn=get(Edit1,''string'');,',... 'n=str2num(strn);,',... 'y1=cos(n.*x);,',... 'plot(x,y1),',... 'grid,',... 'axis([-4 4 -2 2]),',... ]); Button2=uicontrol('parent',h0,... 'units','points',... 'style','pushbutton',... 'string','Button2',... 'fontsize',15,... 'backgroundcolor',[0.8 0.8 0.8],... 'position',[28 70 80 20],... 'callback',[... 'strdn=get(Edit2,''string'');,',... 'dn=str2num(strdn);,',... 'y2=2*exp(-0.7*x).*cos(dn.*x);,',... 'plot(x,y2),',... 'grid,',... 'axis([-4 4 -10 10]),',]); Button3=uicontrol('parent',h0,... 'units','points',... 'tag','b3',... 'style','pushbutton',... 'string','結束',... 'ForegroundColor',[1 0 0],... 'fontsize',24,... 'backgroundcolor',[1 0.5 0.5],... 'position',[185 20 60 40],... 'callback','close');
Edit1=uicontrol('parent',h0,... 'units','points',... 'tag','Edit1',... 'style','edit',... 'fontsize',12,... 'string','5',... 'horizontalalignment','right',... 'backgroundcolor',[0.9 0.9 0.9],... 'position',[210 100 35 20]); Edit2=uicontrol('parent',h0,... 'units','points',... 'tag','Edit2',... 'style','edit',... 'fontsize',12,... 'string','10',... 'horizontalalignment','right',... 'backgroundcolor',[0.9 0.9 0.9],... 'position',[210 70 35 20]);
Label1=uicontrol('parent',h0,... 'units','points',... 'tag','Label1',... 'style','text',... 'string','第一輸入',... 'fontsize',13,... 'backgroundcolor',[0.9 0.8 0.9],... 'position',[149 100 60 20]); Label2=uicontrol('parent',h0,... 'units','points',... 'tag','Label2',... 'style','text',... 'string','第二輸入',... 'fontsize',13,... 'backgroundcolor',[0.9 0.8 0.9],... 'position',[149 70 60 20]);
|