控制仿真基于matlab GUI飞机俯仰角控制模型仿真含Matlab源码 102期
Posted 紫极神光
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了控制仿真基于matlab GUI飞机俯仰角控制模型仿真含Matlab源码 102期相关的知识,希望对你有一定的参考价值。
一、获取代码方式(附课程作业报告)
获取代码方式1:
完整代码已上传我的资源:【控制仿真】基于matlab GUI飞机俯仰角控制模型仿真【含Matlab源码 102期】
获取代码方式2:
通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。
备注:
订阅紫极神光博客付费专栏,可免费获得1份代码(有效期为订阅日起,三天内有效);
二、部分源代码
function varargout = untitled(varargin)
% UNTITLED M-file for untitled.fig
% UNTITLED, by itself, creates a new UNTITLED or raises the existing
% singleton*.
%
% H = UNTITLED returns the handle to a new UNTITLED or the handle to
% the existing singleton*.
%
% UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UNTITLED.M with the given input arguments.
%
% UNTITLED('Property','Value',...) creates a new UNTITLED or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before untitled_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to untitled_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 untitled
% Last Modified by GUIDE v2.5 28-Oct-2021 21:10:14
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled_OpeningFcn, ...
'gui_OutputFcn', @untitled_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin1)
gui_State.gui_Callback = str2func(varargin1);
end
if nargout
[varargout1:nargout] = gui_mainfcn(gui_State, varargin:);
else
gui_mainfcn(gui_State, varargin:);
end
ha=axes('units','normalized','position',[0 0 1 1]);
uistack(ha,'down')
II=imread('1.jpg');
image(II)
colormap gray
set(ha,'handlevisibility','off','visible','off');
% End initialization code - DO NOT EDIT
% --- Executes just before untitled is made visible.
function untitled_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 untitled (see VARARGIN)
% Choose default command line output for untitled
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes untitled wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = untitled_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
varargout1 = handles.output;
% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
valueofslider1=get(handles.slider1,'Value');
set(handles.edit1,'string',num2str(valueofslider1));
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of
% slider
Kp=get(handles.slider1,'Value');
Ki=get(handles.slider2,'Value');
Kd=get(handles.slider3,'Value');
de=0.2;
num=[1.151 0.1774];
den=[1 0.739 0.921 0];
pitch=tf(num,den);
contr=tf([Kd Kp Ki],[1 0]);
sys_cl=feedback(contr*pitch,1);
t=0:0.01:10;
y=step(de*sys_cl,t);
axes(handles.axes2);
plot(t,y);
% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
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
valueofedit1=str2num(get(hObject,'String'));
set(handles.slider1,'Value',valueofedit1);
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
Kp=get(handles.slider1,'Value');
Ki=get(handles.slider2,'Value');
Kd=get(handles.slider3,'Value');
de=0.2;
num=[1.151 0.1774];
den=[1 0.739 0.921 0];
pitch=tf(num,den);
contr=tf([Kd Kp Ki],[1 0]);
sys_cl=feedback(contr*pitch,1);
t=0:0.01:10;
y=step(de*sys_cl,t);
axes(handles.axes2);
plot(t,y);
% --- 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 slider movement.
function slider2_Callback(hObject, eventdata, handles)
% hObject handle to slider2 (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
valueofslider2=get(handles.slider2,'Value');
set(handles.edit2,'String',num2str(valueofslider2));
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
Kp=get(handles.slider1,'Value');
Ki=get(handles.slider2,'Value');
Kd=get(handles.slider3,'Value');
de=0.2;
num=[1.151 0.1774];
den=[1 0.739 0.921 0];
pitch=tf(num,den);
contr=tf([Kd Kp Ki],[1 0]);
sys_cl=feedback(contr*pitch,1);
t=0:0.01:10;
y=step(de*sys_cl,t);
axes(handles.axes2);
plot(t,y);
% --- Executes during object creation, after setting all properties.
function slider2_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
三、运行结果
四、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 门云阁.MATLAB物理计算与可视化[M].清华大学出版社,2013.
以上是关于控制仿真基于matlab GUI飞机俯仰角控制模型仿真含Matlab源码 102期的主要内容,如果未能解决你的问题,请参考以下文章
m基于神经网络的飞机垂直尾翼振动主动控制系统matlab仿真,包括系统辨识和在线控制
飞行器基于matlab GUI四旋翼飞行器PID控制仿真含Matlab源码 1279期