⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lifashi_final.m

📁 我们暑假数学建模过程中编写的理发店模拟系统
💻 M
字号:
function varargout = lifashi_final(varargin)% LIFASHI_FINAL Application M-file for lifashi_final.fig%    FIG = LIFASHI_FINAL launch lifashi_final GUI.%    LIFASHI_FINAL('callback_name', ...) invoke the named callback.% Last Modified by GUIDE v2.0 15-Aug-2005 00:44:45if nargin == 0  % LAUNCH GUI	fig = openfig(mfilename,'reuse');	% Use system color scheme for figure:	set(fig,'Color',get(0,'defaultUicontrolBackgroundColor'));	% Generate a structure of handles to pass to callbacks, and store it. 	handles = guihandles(fig);	guidata(fig, handles);	if nargout > 0		varargout{1} = fig;	endelseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK	try		if (nargout)			[varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard		else			feval(varargin{:}); % FEVAL switchyard		end	catch		disp(lasterr);	endend%| ABOUT CALLBACKS:%| GUIDE automatically appends subfunction prototypes to this file, and %| sets objects' callback properties to call them through the FEVAL %| switchyard above. This comment describes that mechanism.%|%| Each callback subfunction declaration has the following form:%| <SUBFUNCTION_NAME>(H, EVENTDATA, HANDLES, VARARGIN)%|%| The subfunction name is composed using the object's Tag and the %| callback type separated by '_', e.g. 'slider2_Callback',%| 'figure1_CloseRequestFcn', 'axis1_ButtondownFcn'.%|%| H is the callback object's handle (obtained using GCBO).%|%| EVENTDATA is empty, but reserved for future use.%|%| HANDLES is a structure containing handles of components in GUI using%| tags as fieldnames, e.g. handles.figure1, handles.slider2. This%| structure is created at GUI startup using GUIHANDLES and stored in%| the figure's application data using GUIDATA. A copy of the structure%| is passed to each callback.  You can store additional information in%| this structure at GUI startup, and you can change the structure%| during callbacks.  Call guidata(h, handles) after changing your%| copy to replace the stored original so that subsequent callbacks see%| the updates. Type "help guihandles" and "help guidata" for more%| information.%|%| VARARGIN contains any extra arguments you have passed to the%| callback. Specify the extra arguments by editing the callback%| property in the inspector. By default, GUIDE sets the property to:%| <MFILENAME>('<SUBFUNCTION_NAME>', gcbo, [], guidata(gcbo))%| Add any extra arguments after the last argument, before the final%| closing parenthesis.% --------------------------------------------------------------------function varargout = lifashi_Callback(h, eventdata, handles, varargin)% --------------------------------------------------------------------function varargout = guke_Callback(h, eventdata, handles, varargin)% --------------------------------------------------------------------function varargout = pushbutton1_Callback(h, eventdata, handles, varargin)ln=str2double(get(handles.lifashi,'string'));axes(handles.axes1)%理发仿真程序%a(j,i):理发师j在第i分钟正在服务的顾客剩下的时间%c(i):理发店里的顾客总数%d(i):理发店等待的顾客数%S(j) :理发师j的状态,1表示忙,0表示闲%本程序模拟从第1分钟末到第10分钟末理发店的顾客数目,理发师的状态等情况%假设理发师对顾客的服务都是从某分钟的末尾开始的%假设理发师j的工作优先级高于j+1;c(1)=0;d(1)=0;for j=1:ln     S(j)=0;    a(j,1)=0;end for i=2:61    if(rand<=0.5)c(i)=c(i-1)+1;    else c(i)=c(i-1);    end    d(i)=c(i)-sum(S);        for j=1:ln       if(S(j)==0)          if(d(i)>0)             if(rand>0.4)a(j,i)=4;             else a(j,i)=7;             end             S(j)=1;             d(i)=d(i)-1;          else  a(j,i)=0;          end      else a(j,i)=a(j,i-1)-1;      end          if(a(j,i)==0)S(j)=0;        if(a(j,i-1)>0)c(i)=c(i)-1;        end      end   endendi=1:61;plot(i,c(i),'bd',i,d(i),'rp');title('理发师仿真程序');xlabel('第i分钟的状况');ylabel('店内的情况,兰点为顾客总数,红点为等待顾客数')gn=max(d(i));set(handles.guke,'string',gn);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -