Amir Hamzah

Just learning material sharing …
Subscribe

Archive for June, 2012

Fuzzy Quantification Theory 1

June 27, 2012 By: amir Category: Uncategorized No Comments →

Bahan Untuk Latihan FTQ dengan MATLAB
DOWNLOAD
Copy pastekan ke dalam fungsi-fungsi MATLAB sebagai Data :

TUGAS 4 JAVA

June 17, 2012 By: amir Category: Uncategorized No Comments →

BERIKUT INI TUGAS 4 PEMROGRAMAN JAVA
SILAHKAN DOWNLOAD

Fuzzy C-Means Clustering

June 12, 2012 By: amir Category: Fuzzy Logic, Pemrograman No Comments →

Kode MATLAB dalam bentuk file *.txt
DOWNLOAD dan ubah ekstension menjadi *.m
========================================

function [U,V,O]=fcm2(x,c)
[n,m]=size(x);
%% initialization
%% matriks data: n baris x m kolom
w=2;
teta=1e-5;
P0=0;
Pt=0;
OB=[];
%step 1 : Initilize U
U=rand(n,c);
Q=sum(U’)’
for i=1:n
U(i,:)=U(i,:)/Q(i);
end
U
pause
ITER=1;
Obj=1e5;
while (Obj>teta)
%step 2 : update V
Q=sum(U.^w)’;
V=(U’.^w*x);
for i=1:c
V(i,:)=V(i,:)/Q(i);
end;

disp(‘NILAI V’), V
pause
%step 3 : update U from V
for i=1:n
S=0;
for k=1:c
S1=0;
for j=1:m
S1=S1+(x(i,j)-V(k,j))^2;
end
S1=S1^(-1/(w-1));
U(i,k)=S1;
S=S+S1;
end
for k=1:c
U(i,k)=U(i,k)/S;
end
end
disp(‘NILAI U’);U
pause

%step 4 : menghitung F
P0=Pt;
Pt=0;
for i=1:n
for k=1:c
for j=1:m
Pt=Pt+( x(i,j)-V(k,j))^2*U(i,k)^w;
end
end
end
Obj=abs(Pt-P0)

ITER=ITER+1
pause
OB=[OB Obj];
end

O=OB;
% end of function

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Cara penggunaan :
Siapkan data dalam variabel x : dalam format n x m
n=cacah objek
m=dimensi objek
misalnya dalam prompt MATLAB :
>> x=[1 3; 0 4; 4 1; 3 0]

x =

1 3
0 4
4 1
3 0
>>>> fcm2(x,2)

Q =

0.2523
0.8116
1.1852
1.2837

U =

0.3107 0.6893
0.7896 0.2104
0.1611 0.8389
0.6574 0.3426

NILAI V

V =

1.2706 2.3846
2.7171 1.7204

NILAI U

U =

0.9103 0.0897
0.7486 0.2514
0.1877 0.8123
0.2594 0.7406

Obj =

7.5831

ITER =

2

NILAI V

V =

0.7854 3.1931
3.3549 0.7321

NILAI U

U =

0.9923 0.0077
0.9454 0.0546
0.0312 0.9688
0.0420 0.9580

Obj =

5.1949

ITER =

3

NILAI V

V =

0.5283 3.4713
3.4999 0.5113

NILAI U

U =

0.9655 0.0345
0.9776 0.0224
0.0262 0.9738
0.0274 0.9726

Obj =

0.4393

ITER =

4

NILAI V

V =

0.4960 3.5039
3.4981 0.5031

NILAI U

U =

0.9609 0.0391
0.9803 0.0197
0.0262 0.9738
0.0263 0.9737

Obj =

0.0046

ITER =

5

NILAI V

V =

0.4922 3.5078
3.4973 0.5028

NILAI U

U =

0.9603 0.0397
0.9806 0.0194
0.0262 0.9738
0.0262 0.9738

Obj =

6.3781e-005

ITER =

6

NILAI V

V =

0.4917 3.5083
3.4972 0.5028

NILAI U

U =

0.9602 0.0398
0.9806 0.0194
0.0262 0.9738
0.0262 0.9738

Obj =

9.2658e-007

ITER =

7

ans =

0.9602 0.0398
0.9806 0.0194
0.0262 0.9738
0.0262 0.9738

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%