just piece of script

ArrayList<Float> por = new ArrayList<Float>();
ArrayList<Float> jk = new ArrayList<Float>();
ArrayList<Float> jb = new ArrayList<Float>();
ArrayList<Float> v = new ArrayList<Float>();
ArrayList<Float> h = new ArrayList<Float>();
ArrayList<Float> m = new ArrayList<Float>();

for(int j=0; j<jumcent; j++){
por.clear(); jk.clear(); jb.clear(); v.clear(); h.clear(); m.clear();
for(int i=0;i<jumdset;i++){

if(bentukKlaster[j][i] != null){
por.add(Float.parseFloat(tblTampil.getValueAt(i, 1).toString()));
jk.add(Float.parseFloat(tblTampil.getValueAt(i, 2).toString()));
jb.add(Float.parseFloat(tblTampil.getValueAt(i, 3).toString()));
v.add(Float.parseFloat(tblTampil.getValueAt(i, 4).toString()));
h.add(Float.parseFloat(tblTampil.getValueAt(i, 5).toString()));
m.add(Float.parseFloat(tblTampil.getValueAt(i, 6).toString()));
}
}

float sumpor = 0, sumjk = 0, sumjb = 0,sumv =0, sumh=0, summ=0;

//inisialisasi dari sini masih nambah hasil klaster sebelumnya
//dicoba inisialisasi dari luar hasilnya malah nambah banyak

for(int i=0;i<por.size();i++){
sumpor += por.get(i);
sumjk += jk.get(i);
sumjb += jb.get(i);
sumv += v.get(i);
sumh += h.get(i);
summ += m.get(i);
}
//          System.out.println(“sumpor = “+sumpor);

Float[] rata = new Float[6];
rata[0] = sumpor / por.size();
rata[1] = sumjk / jk.size();
rata[2] = sumjb / jb.size();
rata[3] = sumv / v.size();
rata[4] = sumh / h.size();
rata[5] = summ / m.size();

//          System.out.println(“rata por: “+rata[0]);

for(int k = 1; k<7; k++){
cent[j][k] = rata[k-1];
}
}
System.out.println(“Centroid Baru”);
for (int i = 0; i <jumcent; i++) {
System.out.println(cent[i][0].intValue()+”. “+cent[i][1]+” “+cent[i][2]+” “+cent[i][3]+” “+cent[i][4]+” “+cent[i][5]+” “+cent[i][6]);
area.append(cent[i][0].intValue()+”. “+cent[i][1]+”\t”+cent[i][2]+”\t”+cent[i][3]+”\t”+cent[i][4]+”\t”+cent[i][5]+”\t”+cent[i][6]+”\n”);
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s