Matlab 生物节律作图软件

%%基本值分配
startday=[1991 1 1];endday=[year(now) month(now) day(now)];
a=300;x1=0;x2=21; %a为作图中要划分的点数

%%基本框架
hf = figure('units','normalized','position',[0.2 0.3 0.7 0.5],...
    'Resize','off','MenuBar','none',...
    'NumberTitle','off','Name','生物节律作图软件 作者:代号4101');
ha = axes('Parent',hf,'xlim',[x1 x2],...
    'units','normalized','position',[0.05 0.1 0.65 0.8],...
    'NextPlot','add');
% set(ha,'ylim',[0 100]);  %如需固定y轴范围,请在该行左端代码取消注释


%%年月日提醒及输入
uicontrol(hf,'style','text','FontSize',12,...
   'unit','normalized','position',[0.78 0.75 0.12 0.06],...
   'String','请输入出生日期');
uicontrol(hf,'style','text','FontSize',12,...
   'unit','normalized','position',[0.71 0.68 0.02 0.06],...
   'String','年');
uicontrol(hf,'style','edit','FontSize',12,...
    'String',num2str(startday(1)),...
    'unit','normalized','position',[0.73 0.68 0.05 0.06],...
    'callback','startday(1)=str2num(get(gcbo,''string''));');
uicontrol(hf,'style','text','FontSize',12,...
   'unit','normalized','position',[0.8 0.68 0.02 0.06],...
   'String','月');
uicontrol(hf,'style','edit','FontSize',12,...
    'String',num2str(startday(2)),...
    'unit','normalized','position',[0.82 0.68 0.05 0.06],...
    'callback','startday(2)=str2num(get(gcbo,''string''));');
uicontrol(hf,'style','text','FontSize',12,...
   'unit','normalized','position',[0.89 0.68 0.02 0.06],...
   'String','日');
uicontrol(hf,'style','edit','FontSize',12,...
    'String',num2str(startday(3)),...
    'unit','normalized','position',[0.91 0.68 0.05 0.06],...
    'callback','startday(3)=str2num(get(gcbo,''string''));');
uicontrol(hf,'style','text','FontSize',12,...
   'unit','normalized','position',[0.78 0.6 0.12 0.06],...
   'String','请输入查询日期');
uicontrol(hf,'style','text','FontSize',12,...
   'unit','normalized','position',[0.71 0.53 0.02 0.06],...
   'String','年');
uicontrol(hf,'style','edit','FontSize',12,...
    'String',num2str(year(now)),...
    'unit','normalized','position',[0.73 0.53 0.05 0.06],...
    'callback','endday(1)=str2num(get(gcbo,''string''));');
uicontrol(hf,'style','text','FontSize',12,...
   'unit','normalized','position',[0.8 0.53 0.02 0.06],...
   'String','月');
uicontrol(hf,'style','edit','FontSize',12,...
    'String',num2str(month(now)),...
    'unit','normalized','position',[0.82 0.53 0.05 0.06],...
    'callback','endday(2)=str2num(get(gcbo,''string''));');
uicontrol(hf,'style','text','FontSize',12,...
   'unit','normalized','position',[0.89 0.53 0.02 0.06],...
   'String','日');
uicontrol(hf,'style','edit','FontSize',12,...
    'String',num2str(day(now)),...
    'unit','normalized','position',[0.91 0.53 0.05 0.06],...
    'callback','endday(3)=str2num(get(gcbo,''string''));')

%%横坐标范围
uicontrol(hf,'style','text','FontSize',12,...
   'unit','normalized','position',[0.78 0.45 0.12 0.06],...
   'String','设置横坐标范围');
uicontrol(hf,'style','text','FontSize',12,...
   'unit','normalized','position',[0.74 0.38 0.02 0.06],...
   'String','左');
uicontrol(hf,'style','edit','FontSize',12,...
    'String',num2str(x1),...
    'unit','normalized','position',[0.76 0.38 0.05 0.06],...
    'callback','x1=str2num(get(gcbo,''string''));')
uicontrol(hf,'style','text','FontSize',12,...
   'unit','normalized','position',[0.84 0.38 0.02 0.06],...
   'String','右');
uicontrol(hf,'style','edit','FontSize',12,...
    'String',num2str(x2),...
    'unit','normalized','position',[0.86 0.38 0.05 0.06],...
    'callback','x2=str2num(get(gcbo,''string''));')

%%体力、情绪、智力、clear按钮
grid on
uicontrol('Style','pushbutton',...
    'BackgroundColor','r','FontSize',12,...
    'Callback',['days=datenum(endday)-datenum(startday);','X = linspace(x1,x2,a);'...
    'set(ha,''xlim'',[x1 x2]);',...
    'for i=1:a;',...
    'Y(i)=50*sin(2*pi*(days+X(i))/23)+50;',...
    'end;','plot(X,Y,''Color'',''r'');','grid on'],...
    'String','体力',...
    'Units','normalized',...
    'Position',[0.72 0.25 0.1 0.08]);
uicontrol('Style','pushbutton',...
    'BackgroundColor','g','FontSize',12,...
    'Callback',['days=datenum(endday)-datenum(startday);','X = linspace(x1,x2,a);'...
    'set(ha,''xlim'',[x1 x2]);',...
    'for i=1:a;',...
    'Y(i)=50*sin(2*pi*(days+X(i))/28)+50;',...
    'end;','plot(X,Y,''Color'',''g'');','grid on'],...
    'String','情绪',...
    'Units','normalized',...
    'Position',[0.84 0.25 0.1 0.08]);
uicontrol('Style','pushbutton',...
    'BackgroundColor','b','FontSize',12,...
    'Callback',['days=datenum(endday)-datenum(startday);','X = linspace(x1,x2,a);'...
    'set(ha,''xlim'',[x1 x2]);',...
    'for i=1:a;',...
    'Y(i)=50*sin(2*pi*(days+X(i))/33)+50;',...
    'end;','plot(X,Y,''Color'',''b'');','grid on'],...
    'String','智力',...
    'Units','normalized',...
    'Position',[0.72 0.15 0.1 0.08]);
uicontrol('Style','pushbutton','FontSize',12,...
    'Callback','try,delete(allchild(ha));grid on;end',...
    'String','clear',...
    'Units','normalized',...
    'Position',[0.84 0.15 0.1 0.08]);

你可能感兴趣的:(Matlab,应用开发)