A list,

Matlab GUI based inverted pendulum system

Ii. Source code

function varargout = pendulum(varargin)
% PENDULUM M-file for pendulum.fig
%      PENDULUM, by itself, creates a new PENDULUM or raises the existing
%      singleton*.
%
%      H = PENDULUM returns the handle to a new PENDULUM or the handle to
%      the existing singleton*.
%
%      PENDULUM('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in PENDULUM.M with the given input arguments.
%
%      PENDULUM('Property'.'Value',...). creates anew PENDULUM or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before pendulum_OpeningFunction gets called.  An
%      unrecognized property name orinvalid value makes property application % stop. All inputs are passed to pendulum_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 pendulum

% Last Modified by SHE on 15-Dec- 2020. 22:08:58

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @pendulum_OpeningFcn, ...
                   'gui_OutputFcn',  @pendulum_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 pendulum is made visible.
function pendulum_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 pendulum (see VARARGIN)

% Choose default command line output for pendulum
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes pendulum wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = pendulum_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;



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% stores the contents of data textbox 1 as a string. If the string is not a number, then the real blank content input=str2double(get(hObject,'String')); % checks if the input is null. If it is empty, it is displayed by default0
if (isempty(input))     
set(hObject,'String'.'0')
end
guidata(hObject, handles);

% --- 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
    set(hObject,'BackgroundColor'.'white');
else
    set(hObject,'BackgroundColor',get(0.'defaultUicontrolBackgroundColor'));
end



function edit2_Callback(hObject, eventdata, handles)
% hObject    handle to edit2 (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 edit2 as text
%        str2double(get(hObject,'String')) returns contents of edit2 as a double% stores the contents of data textbox 2 as a string. If the string is not a number, then the real blank content input=str2double(get(hObject,'String')); % checks if the input is null. If it is empty, it is displayed by default0
if (isempty(input))     
set(hObject,'String'.'0')
end
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2 (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
    set(hObject,'BackgroundColor'.'white');
else
    set(hObject,'BackgroundColor',get(0.'defaultUicontrolBackgroundColor'));
end



function edit3_Callback(hObject, eventdata, handles)
% hObject    handle to edit3 (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 edit3 as text
%        str2double(get(hObject,'String')) returns contents of edit3 as a double% stores the contents of data textbox 3 as a string. If the string is not a number, then the real blank content input=str2double(get(hObject,'String')); % checks if the input is null. If it is empty, it is displayed by default0
if (isempty(input))    
set(hObject,'String'.'0')
end
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit3 (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
    set(hObject,'BackgroundColor'.'white');
else
    set(hObject,'BackgroundColor',get(0.'defaultUicontrolBackgroundColor'));
end



function edit4_Callback(hObject, eventdata, handles)
% hObject    handle to edit4 (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 edit4 as text
%        str2double(get(hObject,'String')) returns contents of edit4 as a double% stores the contents of data textbox 4 as a string. If the string is not a number, then the real blank content input=str2double(get(hObject,'String')); % checks if the input is null. If it is empty, it is displayed by default0
if (isempty(input))     
set(hObject,'String'.'0')
end
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit4 (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
    set(hObject,'BackgroundColor'.'white');
else
    set(hObject,'BackgroundColor',get(0.'defaultUicontrolBackgroundColor'));
end



function edit5_Callback(hObject, eventdata, handles)
% hObject    handle to edit5 (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 edit5 as text
%        str2double(get(hObject,'String')) returns contents of edit5 as a double% stores the contents of the data textbox 5 as a string. If the string is not a number, then the real blank content input=str2double(get(hObject,'String')); % checks if the input is null. If it is empty, it is displayed by default0
if (isempty(input))     
set(hObject,'String'.'0')
end
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit5 (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
    set(hObject,'BackgroundColor'.'white');
else
    set(hObject,'BackgroundColor',get(0.'defaultUicontrolBackgroundColor'));
end


% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu1
popup_sel_index = get(handles.popupmenu1, 'Value');
popup_sel_index = get(handles.popupmenu1, 'Value');
switch popup_sel_index
    case 1
        set(handles.text10 ,'String'.'Pole of expectation');
        set(handles.text11 ,'String'.'- 10-10');
        set(handles.text12 ,'String'.'-2+2*sqrt(3)*i -2-2*sqrt(3)*i');
    case 2
        set(handles.text10 ,'String'.'Weighted matrix');
        set(handles.text11 ,'String'.'Q=[1 0 0 0; 0 0 0 0; 0 0 1 0;0 0 0 0]; ');
        set(handles.text12 ,'String'.' R=1');
    case 3
        set(handles.text10 ,'String'.'Reference input');
        set(handles.text11 ,'String'.'y_r = 0.2 * U (t)');
        set(handles.text12 ,'String'.' ');
     case 4
        set(handles.text10 ,'String'.'PID');
        set(handles.text11 ,'String'.'  P=5,I=0.001,D=1');
        set(handles.text12 ,'String'.' ');    
end
Copy the code

3. Operation results

Fourth, note

Version: 2014 a