📄 pendulum.m
字号:
%PENDULUM A ball balancing simulator that uses fuzzy logic
%
% PENDULUM 3.0 - A BALL BALANCING SIMULATOR
%
%
% Simulates linear and fuzzy control strategies for a ball balancing
% system. Version 1.0 written by prof. Jan Jantzen, Danmarks Tekniske
% Universitet. Version 2.0, to run under Matlab SE 4.0, written by
% Petur Snaeland, M.Sc. student, May 1995.
%
% The program does not clear or alter the Matlab environment. All its
% variables are cleared when the user selects the Exit button or menu
% command.
%
% Program execution is similar to that of event-driven programs. Control
% flow is therefore not continuous, since user-interface objects trigger
% command execution as they are activated by the user. However, the same
% subroutine, doevent(strEvent), is always called when events are fired.
% There, any response to user interaction is determined.
%
% Version 1.0, Jan Jantzen, Danmarks Tekniske Universitet
% Version 2.0, Petur Snaeland, May 1995
% Version 3.0, Hordur Kvaran, 20.10.97
function pendulum
% Initialization file for the Pendulum simulator.
% As pendulum is declared as a function it will have a completely independent
% workspace. To access variables at runtime it is necessary to declare them global.
% Hordur Kvaran, 20.10.97
% Check if the Pendulum simulator is running.
% Put focus on the simulator if it is
hPendul = findobj('Type','figure','Name','Ball Balancing Simulator','Tag','wndMain');
if ~isempty(hPendul),
disp('Pendulum simulator already running');
figure(hPendul);
clear hPendul figHandles;
return;
end;
clear hPendul;
disp(''); % (Just to cut off the help screen)
pendul2; % Run the main setup.
% If you read this file and come across this, I recommend using the following
% IF IT WORKS ON YOUR SYSTEM. This does not work on all systems (I don't know why)
% This is done because the pendulum needs access to files that are in the pendulum
% directory, such as the .mat files and the rulebases. (cartbase.txt and ballbase.txt)
% If you start the pendulum in a directory that does NOT contain those files,
% pendulum will crash.
% Idea: If the pendulum simulator is not in Matlab path it has been invoked from current
% dir. Otherwise change into the pendulum directory and continue from there.
%
%pendpath=which('pendulum'); % Which only find .m(at) files in the PATH. Not current dir
%if (isempty(pendpath) | ~isempty(findstr(pendpath,'not found')))
% clear pendpath;
% pendul2;
%else
% num=findstr(pendpath,'pendulum.m'); % Find the filename within the path
% cd(pendpath(1:num-1)); % Change into the directory (without the filename)
% clear num pendpath;
% pendul2;
%end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -