温度控制系统一.温度控制系统概述:本设计是利用MATLAB软件仿真技术实现的温度控制系统演示动画。水的温度以一个下限温度(本设计为27℃)起始,该系统启动,并对水进行加热,使其温度持续上升,直至上限温度(本设计为100℃),之后为使温度保持在60℃-100℃范围内,则该系统开始冷却,直至中间温度60℃,系统又开始对水加热至100摄氏度,再冷却至60摄氏度,如此循环,即可实现水温控制在60℃-100℃范围内保持不变。分别有指示灯指示。二.温度控制系统程序:hf=figure('name','温度控制系统','color',[.96.96.96]);%设置标题名字axis([-11-11]);axis('off');holdon;x1=[0.20.20.40.4];y1=[-0.46-1-1-0.46];t=-0.46;%存储温度纵坐标k=1;k1=1;%k为运行标志位,当k=1时,运行;当k=0时,停止;k1为温度上下降标志位,当k1=1时,温度上升;当k1=0时,温度下降line([0.2;0.2],[1;-1],'color','k','linewidth',2);%温度区域左边line([0.2;0.4],[-1;-1],'color','k','linewidth',2);%温度区域下边line([0.4;0.4],[1;-1],'color','k','linewidth',2);%温度区域右边line([0.2;0.4],[1;1],'color','k','linewidth',2);%温度区域上边line([0.4;0.5],[1;1],'color','r','linewidth',2);%刻度标记100text(0.5,1,'100摄氏度','color','r');line([0.4;0.5],[0.2;0.2],'color','b','linewidth',2);%刻度标记60text(0.5,0.2,'60摄氏度','color','b');line([0.4;0.5],[-0.46;-0.46],'color','g','linewidth',2);%刻度标记27text(0.5,-0.46,'室温27摄氏度','color','g');pp=line([0.2;0.4],[-0.46;-0.46],'color','r','linewidth',3);Fun1=plot(-0.95,0.6,'color','k','marker','.','markersize',30);%加热显示text(-1,0.5,'加热');Fun2=plot(-0.5,0.6,'color','k','marker','.','markersize',30);%冷却显示text(-0.55,0.5,'冷却');Fun3=plot(-0.95,0.2,'color','k','marker','.','markersize',30);%电源开显示text(-1,0.1,'ON');Fun4=plot(-0.5,0.2,'color','r','marker','.','markersize',30);%电源关显示text(-0.53,0.1,'OFF');text(-0.9,0,'电源指示灯');%停止按钮pushbutton1=uicontrol(hf,...'units','normalized',...'style','pushbutton',...'string','停止',...'backgroundcolor',[0.750.750.75],...'position',[0.10.30.10.1],...'callback','k=0;');%关闭按钮pushbutton2=uicontrol(hf,...'units','normalized',...'style','pushbutton',...'string','关闭',...'backgroundcolor',[0.750.750.75],...'position',[0.30.30.10.1],...'callback','close');temp=patch(x1,y1,[011]);%初始温度whilek==1%产生温度上升、下降动画set(Fun4,'color','k');set(Fun3,'color','r');ifk1==1%温度上升set(Fun1,'color','r');set(Fun2,'color','k');fori=1:1600a=t+(1-t)/1600*i;y1=[a-1-1a];set(temp,'ydata',y1);set(pp,'ydata',[a,a]);drawnow;endt=a;k1=0;elseifk1==0%温度下降set(Fun1,'color','k');set(Fun2,'color','r');fori=1:1000a=t-(t-0.2)/1000;y1=[a-1-1a];set(temp,'ydata',y1);set(pp,'ydata',[a,a]);drawnow;endt=a;k1=1;endendendset(Fun1,'color','k');%停止还原set(Fun2,'color','k');set(Fun3,'color','k');set(Fun4,'color','r');二.温度控制系统动画截图:1.开启系统,则系统以27℃的下限温度开始加热:电源指示灯和加热指示灯同时点亮:2.温度低于中间温度,系统处于加热状态:加热指示灯仍旧点亮3.温度高于中间温度,系统仍处于加热状态:4.当温度到达上限温度100℃,系统开始冷却:冷却指示灯点亮,加热指示灯熄灭。5.冷却至中间温度(或低于)60℃,系统重新开始加热:加热指示灯重新点亮5.按停止按钮,使系统退出温度保持状态:电源指示灯熄灭