《系统仿真与matlab》综合试题题目:曲柄滑块机构的运动学仿真编号:21难度系数:姓名班级学号联系方式成绩《系统仿真与matlab》综合试题 (1)一、引言 (3)二、运动学分析 (3)1、实例题目 (3)2、运动分析 (3)三、MATLAB程序编写 (5)四、使用指南和实例仿真 (8)五、结语 (10)一、引言曲柄滑块机构是指用曲柄和滑块来实现转动和移动相互转换的平面连杆机构,也称曲柄连杆机构。
曲柄滑块机构广泛应用于往复活塞式发动机、压缩机、冲床等的主机构中,把往复移动转换为不整周或整周的回转运动;压缩机、冲床以曲柄为主动件,把整周转动转换为往复移动。
这里使用运动学知识,对其运动进行解析,并用MATLAB为其设计仿真模块。
二、运动学分析1、实例题目对图示单缸四冲程发动机中常见的曲柄滑块机构进行运动学仿真。
已知连杆长度:m r 1.02=,m r 4.03=,连杆的转速:22θω =,33θω =,设曲柄r 2以匀速旋转,s r / 502=ω。
初始条件:032==θθ。
仿真以2ω为输入,计算3ω和1r,仿真时间0.5s 。
2、运动分析建立封闭矢量方程:r2+r3=r1 (9)将(9)式分解到x与y轴坐标上,得到:r2cosθ2+r3cosθ3=r1r2sinθ2+r3sinθ3=0 (10) 可得:r1=r2cosθ2+r3cosθ3θ3=-arcsin(r2/r3) (11) 对(10)式对时间求导得:-r2ω2sinθ2+r3ω3sinθ3=v1r2ω2cosθ2+ r3ω3cosθ3=0(12) 将上式用矩阵形式表示,令:A=[ r3sinθ3 1-r3cosθ30]X=[ ω3v1]B=[-r2ω2sinθ2r2ω2cosθ2]则(12)可表示为:AX=B。
(13)从而可解出ω3与v1。
三、MATLAB程序编写源代码如下:function varargout = z1(varargin)% Z1 MATLAB code for z1.fig% Z1, by itself, creates a new Z1 or raises the existing% singleton*.%% H = Z1 returns the handle to a new Z1 or the handle to% the existing singleton*.%% Z1('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in Z1.M with the given input arguments.%% Z1('Property','Value',...) creates a new Z1 or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before z1_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application % stop. All inputs are passed to z1_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 z1% Last Modified by GUIDE v2.5 29-Dec-2016 22:57:13% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ...'gui_Singleton', gui_Singleton, ...'gui_OpeningFcn', @z1_OpeningFcn, ...'gui_OutputFcn', @z1_OutputFcn, ...'gui_LayoutFcn', [] , ...'gui_Callback', []);if nargin && ischar(varargin{1})gui_State.gui_Callback = str2func(varargin{1});endif nargout[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); elsegui_mainfcn(gui_State, varargin{:});end% End initialization code - DO NOT EDIT% --- Executes just before z1 is made visible.function z1_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 z1 (see VARARGIN)% Choose default command line output for z1handles.output = hObject;% Update handles structureguidata(hObject, handles);axes(handles.axes3)map1=imread('1.bmp');imshow(map1)% UIWAIT makes z1 wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line. function varargout = z1_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;% --- Executes on button press in pushbuttonRun.function pushbuttonRun_Callback(hObject, eventdata, handles)%主要计算程序r2=0.1;%单位mr3=0.4;%单位momiga2=str2double(get(handles.edit1,'String'));; %单位rad/sx11=1:500 %单位msfor i=1:500theta2(i)=i*omiga2/1000;theta3(i)=asin(-r2/r3*sin(theta2(i)));B=[-r2*omiga2*sin(theta2(i));r2*omiga2*cos(theta2(i))];A=[r3*sin(theta3(i)) 1;-r3*cos(theta3(i)) 0];X=inv(A)*B;omiga3(i)=X(1,1);v3(i)=X(2,1);endaxes(handles.axes1) %制表1plot(x11/1000,omiga3);xlabel('时间(t/s)')ylabel('连杆角速度ω3(rad/s)')axes(handles.axes2) %制表2plot(x11/1000,v3);xlabel('时间(t/s)')ylabel('滑块速度v1(m/s)')% hObject handle to pushbuttonRun (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)function edit1_Callback(hObject, eventdata, handles)% hObject handle to edit1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit1 as text% str2double(get(hObject,'String')) returns contents of edit1 as a double% --- Executes during object creation, after setting all properties.function edit1_CreateFcn(hObject, eventdata, handles)% hObject handle to edit1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end% --- Executes on button press in pushbuttonExit.function pushbuttonExit_Callback(hObject, eventdata, handles)ss=questdlg('确认退出?','退出信息窗口!','继续仿真!','退出仿真!','退出仿真!'); switch sscase '退出仿真!'delete(handles.figure1);end% hObject handle to pushbuttonExit (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)四、使用指南和实例仿真进入MATLAB软件,打开并运行程序。