|
M-file Matlab Function for
Fuzzy System
Diagram block of fuzzy control systems that will simulate a PD-like
fuzzy control structure is shown in Figure 1, the fuzzy system has two
inputs proportional and derivative, with the Gp is the proportional
gain, Gd is the gain of the derivative and Go is a gain of the output.

Figure 1. Block Diagram for PD-like Fuzzy Controller
The
simulation begins by setting the value of the initial conditions of the
plant, and controller errors. Then step into the program looping process
that took place during the time that we want (by considering the
sampling time). Every time entering the iteration k, error (k) is
calculated using Equation 1. Then the changing value of error
(derivative error) is calculated by equation 2. After the error values
and error change obtained, then the value is inserted into the fuzzy
logic system so that the output obtained that will be used as plant
input . With this plant input, then the plant output can be calculated.
Next to the next iteration. This process can be seen in Figure 2:
(1)
(2)

Figure 2. Flowchart of Fuzzy Control Sistem Simulation
to
simulate this system, we can download the functions first
1.
Left membership
2.
Center membership
3.
Right membership
4.
Fuzzy controller
5.
Satelit plant
save them to work folder at matlab, and then write the script below
clear;
x1(1)=0;
x2(1)=0;
y(1)=0;
dt=0.01;
u(1)=1;
r=0.5
e(1)=-r;
gp=1;
gd=1;
go=1;
for n=1:1000
k=n+1;
e(k)=r-y(k-1);
de(k)=100*(e(k)-e(k-1));
u(k)=go*fuzz_satelit(gp*e(k),gd*de(k));
%u(k)=e(k);
[x1(k),x2(k)]=f_satelit(dt,u(k-1),x1(k-1),x2(k-1));
y(k)=x1(k);
end
t=linspace(0,10,1001);
figure;
plot(t,y);
xlabel('detik');
ylabel('rad');
after then, execute the script that resulting the figure below

we
can change the value of Gp, Gd and Go for the best result.
|