一、获取代码方式
获取代码方式1:
完整代码已上传我的资源:【机械仿真】基于matlab GUI凸轮设计与仿真【含Matlab源码 153期】
二、部分源代码
function varargout = XnqxGUI(varargin)
% XNQXGUI M-file for XnqxGUI.fig
% XNQXGUI, by itself, creates a new XNQXGUI or raises the existing
% singleton*.
%
% H = XNQXGUI returns the handle to a new XNQXGUI or the handle to
% the existing singleton*.
%
% XNQXGUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in XNQXGUI.M with the given input arguments.
%
% XNQXGUI('Property','Value',...) creates a new XNQXGUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before XnqxGUI_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to XnqxGUI_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
% Copyright 2002-2003 The MathWorks, Inc.
% Edit the above text to modify the response to help XnqxGUI
% Last Modified by GUIDE v2.5 03-Jun-2021 11:14:18
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @XnqxGUI_OpeningFcn, ...
'gui_OutputFcn', @XnqxGUI_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 XnqxGUI is made visible.
function XnqxGUI_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 XnqxGUI (see VARARGIN)
% Choose default command line output for XnqxGUI
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes XnqxGUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = XnqxGUI_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 TlyljPush.
function TlyljPush_Callback(hObject, eventdata, handles)
% hObject handle to TlyljPush (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
cla
load Tljgcs
load mycamdata
load Cdjjgcs
if CdjType<3
tanvalue=(dsdphi+flagPzfx*Pj)./(sqrt(r0^2-Pj^2)+s);
alpha=abs(atan(tanvalue));
alpha=alpha*180/pi;
else
alpha=0;
end
plot(phi,alpha);
hold on
xlabel('凸轮转角(°)');
ylabel('从动件压力角(°)');
title('从动件压力角曲线');
alphamax=max(alpha);
plot(phi,alphamax);
axis([0 360 0 90]);
hold off
save Ylj alpha
% --- Executes on button press in QlbjqxPush.
function QlbjqxPush_Callback(hObject, eventdata, handles)
% hObject handle to QlbjqxPush (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
cla
load Tljgcs
load mycamdata
load Cdjjgcs
e=Pj;rt=Gzbj;
[rho0,rho1]=TlQlbj(r0,s,phi,dsdphi,ds2dphi2,rt,e);
plot(phi,rho0);
%pause
plot(phi,rho1);
xlabel('凸轮转角(°)');
ylabel('轮廓曲率半径(mm)');
title('凸轮轮廓曲率半径曲线');
axis([0 360 -15 15]);
save qlbj rho1
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close
三、运行结果
四、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 门云阁.MATLAB物理计算与可视化[M].清华大学出版社,2013.
[2]王增胜,朱煜钰,孔令云.曲柄摇杆机构运动分析与仿真[J].机械工程与自动化. 2014,(01)