M.K.H.Gunasekara - AS2010377 CSC 367 2.0 Mathematical Computing
11 | P a g e
Appendices
MATLAB Sourcecode for RBF Network with MLP Network
clc
clear all
% M.K.H. Gunasekara
% AS2010377
% Machine Learning
% Radial Basis Function
[arr tx] = xlsread('data.xls');
Centers=zeros(3,4);
% I found centers as mean of the same cluster values
for i=1:50
Centers(1,1)=arr(i,1)+Centers(1,1);
Centers(1,2)=arr(i,2)+Centers(1,2);
Centers(1,3)=arr(i,3)+Centers(1,3);
Centers(1,4)=arr(i,4)+Centers(1,4);
end
for i=51:100
Centers(2,1)=arr(i,1)+Centers(2,1);
Centers(2,2)=arr(i,2)+Centers(2,2);
Centers(2,3)=arr(i,3)+Centers(2,3);
Centers(2,4)=arr(i,4)+Centers(2,4);
end
for i=101:150
Centers(3,1)=arr(i,1)+Centers(3,1);
Centers(3,2)=arr(i,2)+Centers(3,2);
Centers(3,3)=arr(i,3)+Centers(3,3);
Centers(3,4)=arr(i,4)+Centers(3,4);
end
for j= 1:3
Centers(j,1)=Centers(j,1)/50;
Centers(j,2)=Centers(j,2)/50;
Centers(j,3)=Centers(j,3)/50;
Centers(j,4)=Centers(j,4)/50;
end
Centers
% OR we can use k means algorithms calculate cluster centers
k=3; %number of clusters
[IDX,C]=kmeans(arr,k);
C %RBF centres
%Uncomment following line to use k means
%Centers=C;