function varargout = wodedianti(varargin)
% WODEDIANTI M-file for wodedianti.fig
% WODEDIANTI, by itself, creates a new WODEDIANTI or raises the existing
% singleton*.
%
% H = WODEDIANTI returns the handle to a new WODEDIANTI or the handle to
% the existing singleton*.
%
% WODEDIANTI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in WODEDIANTI.M with the given input arguments.
%
% WODEDIANTI('Property','Value',...) creates a new WODEDIANTI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before wodedianti_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to wodedianti_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
%
% Edit the above text to modify the response to help wodedianti
% Last Modified by GUIDE v2.5 27-Dec-2020 11:47:37
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @wodedianti_OpeningFcn, ...
'gui_OutputFcn', @wodedianti_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before wodedianti is made visible.
function wodedianti_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to wodedianti (see VARARGIN)
% Choose default command line output for wodedianti
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes wodedianti wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = wodedianti_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
global k;
k=0;
global k1;
global x1;
global x2;
global y1;
global s0;
s0=0;
global s1;
global s2;
global s3;
global s4;
global s5;
global s6;
global s7;
global s8;
global door1;
global door2;
global e1;
axes(handles.axes1);
axis([-2.0,15.0,-2.0,15.0])%坐标轴的范围
hold on
fill([-2,15,15,-2],[-2,-2,15,15],[0.4,0.2,0.2]);
x1=[9.5 9.5 10 10];
y1=[1 0 0 1];
x2=[10 10 10.5 10.5];
text(0,4,'学号:100408623 100408921','fontsize',15,'color','c');
text(0,5,'姓名:沈霄 龙阳莉','fontsize',15,'color','c');
text(-1,9,'上升','fontsize',10,'color','c');
text(4,9,'下降','fontsize',10,'color','c');
text(6,11.5,'控制电机','fontsize',10,'color','c');
text(11.5,0,'一楼','fontsize',10,'color','c');
text(11.5,1,'二楼','fontsize',10,'color','c');
text(11.5,2,'三楼','fontsize',10,'color','c');
text(11.5,3,'四楼','fontsize',10,'color','c');
text(11.5,4,'五楼','fontsize',10,'color','c');
text(11.5,5,'六楼','fontsize',10,'color','c');
text(11.5,6,'七楼','fontsize',10,'color','c');
text(11.5,7,'八楼','fontsize',10,'color','c');
text(11.5,8,'九楼','fontsize',10,'color','c');
text(11.5,9,'十楼','fontsize',10,'color','c');
l0=line([11;11],[0;10],'color','c','linestyle','-','linewidth',2);
line([11;11.2],[0;0],'color','r','linestyle','-','linewidth',2);
line([11;11.2],[1;1],'color','r','linestyle','-','linewidth',2);
line([11;11.2],[2;2],'color','r','linestyle','-','linewidth',2);
line([11;11.2],[3;3],'color','r','linestyle','-','linewidth',2);
line([11;11.2],[4;4],'color','r','linestyle','-','linewidth',2);
line([11;11.2],[5;5],'color','r','linestyle','-','linewidth',2);
line([11;11.2],[6;6],'color','r','linestyle','-','linewidth',2);
line([11;11.2],[7;7],'color','r','linestyle','-','linewidth',2);
line([11;11.2],[8;8],'color','r','linestyle','-','linewidth',2);
line([11;11.2],[9;9],'color','r','linestyle','-','linewidth',2);
l1=line([2;5.5],[13;13],'color','c','linestyle','-','linewidth',2);
l2=line([2;2],[11;13],'color','c','linestyle','-','linewidth',2);
l3=line([1;1],[9;11],'color','c','linestyle','-','linewidth',2);
l4=line([3;3],[9;11],'color','c','linestyle','-','linewidth',2);
l5=line([1;3],[11;11],'color','c','linestyle','-','linewidth',2);%绘制导线
k1=line([2;1],[8;9],'color','r','linestyle','-','linewidth',2);%单刀双掷开关
door1=patch(x1,y1,[0 1 1]);
door2=patch(x2,y1,[0 1 1]);%画电梯的两面门
t=0:pi/100:2*pi;
fill(6+0.5*sin(t),13+cos(t),[0.7,0.85,0.9]);%电机左端
fill(8.5+0.5*sin(t),13+cos(t),[0.7,0.85,0.9]);%电机右端
e0=line([9;10],[13;13],'color','r','linewidth',2);%
e1=line([10;10],[1;13],'color','b','linewidth',2);%连接电机中轴和电梯的线
s1=line([6;8.5],[14;14],'color','c','linestyle','-','linewidth',2);
s2=line([6;8.5],[12;12],'color','m','linestyle','-','linewidth',2);
s3=line([6;8.5],[14;14],'color','b','linestyle','-','linewidth',2);
s4=line([6;8.5],[12;12],'color','w','linestyle','-','linewidth',2);
s5=line([6;8.5],[14;14],'color','k','linestyle','-','linewidth',2);
s6=line([6;8.5],[12;12],'color','g','linestyle','-','linewidth',2);
s7=line([6;8.5],[14;14],'color','r','linestyle','-','linewidth',2);
s8=line([6;8.5],[12;12],'color','b','linestyle','-','linewidth',2);
%电梯上升函数:
function y=moveup(f1,f2)
global k;%全局变量
global k1;%全局变量
global x1;%全局变量
global x2;%全局变量
global y1;%全局变量
global s0;%全局变量
global s1;%全局变量
global s2;%全局变量
global s3;%全局变量
global s4;%全局变量
global s5;%全局变量
global s6;%全局变量
global s7;%全局变量
global s8;%全局变量
global door1;%全局变量
global door2;%全局变量
global e1;%全局变量
a=0; %设定电机运转的初始角度
da=0.05;%设定电机正转的条件
s=f1; %设定门运动的初始条件
ds=0.05;%设定门运动的周期
while s<f2 %条件表达式 (当p1<s<p2时,电机正转,门上升)
a=a+da;
xa1=6+abs(0.5*sin(a)); %当线运动到电机背面时会覆盖电机左端,用abs可解决这一问题增强逼真感)
xa2=8.5+0.5*sin(a);
ya1=13+cos(a);
ya2=13+cos(a);%设定s1的两端点坐标(s1是对应0的线)
xb1=6+0.5*abs(sin(a+pi));
xb2=8.5+0.5*sin(a+pi);
yb1=13+cos(a+pi);
yb2=13+cos(a+pi); %设定s2的两端点坐标(s2是对应pi的线)
xc1=6+abs(0.5*sin(a+pi/2));
xc2=8.5+0.5*sin(a+pi/2);
yc1=13+cos(a+pi/2);
yc2=13+cos(a+pi/2);%设定s3的两端点坐标(s3是对应pi/2的线)
xd1=6+0.5*abs(sin(a-pi/2));
xd2=8.5+0.5*sin(a-pi/2);
yd1=13+cos(a-pi/2);
yd2=13+cos(a-pi/2);%设定s4的两端点坐标(s4是对应-pi/2的线)
xe1=6+abs(0.5*sin(a+pi/4));
xe2=8.5+0.5*sin(a+pi/4);
ye1=13+cos(a+pi/4);
ye2=13+cos(a+pi/4);%设定s5的两端点坐标(s5是对应pi/4的线)
xf1=6+0.5*abs(sin(a+pi*3/4));
xf2=8.5+0.5*sin(a+pi*3/4);
yf1=13+cos(a+pi*3/4);
yf2=13+cos(a+pi*3/4);%设定s6的两端点坐标(s6是对应pi*3/4的线)
xg1=6+abs(0.5*sin(a-pi*3/4));
xg2=8.5+0.5*sin(a-3*pi/4);
yg1=13+cos(a-3*pi/4);
yg2=13+cos(a-3*pi/4);%设定s7的两端点坐标(s7是对应-3*pi/4的线)
xh1=6+0.5*abs(sin(a-pi/4));
xh2=8.5+0.5*sin(a-pi/4);
yh1=13+cos(a-pi/4);
yh2=13+cos(a-pi/4); %设定s8的两端点坐标(s8是对应-pi/4的线)
set(s1,'xdata',[xa1;xa2],'ydata',[ya1;ya2]);
set(s2,'xd
- 1
- 2
前往页