Program Matlab Perataan histogram


function ratahistrogram

 

baris=6;

kolom=6;

derajatkeabuan=15;

awal=zeros(baris,kolom);

akhir=zeros(baris,kolom);

kemunculan=zeros(1,derajatkeabuan);

probkemunculan=zeros(1,derajatkeabuan);

sumprobkemunculan=zeros(1,derajatkeabuan);

 

awal=[2 8 9 8 10 12;12 6 6 7 10 11;5 8 9 8 7 7;6 7 11 12 11 12;9 9 12 10 10 9;5 6 5 6 5 5]

 

for i=1:baris;

for j=1:kolom;

switch awal(i,j);

case 0

kemunculan(0)=kemunculan(0)+1;

probkemunculan(0)=kemunculan(0)/(baris*kolom);

case 1

kemunculan(1)=kemunculan(1)+1;

probkemunculan(1)=kemunculan(1)/(baris*kolom);

case 2

kemunculan(2)=kemunculan(2)+1;

probkemunculan(2)=kemunculan(2)/(baris*kolom);

case 3

kemunculan(3)=kemunculan(3)+1;

probkemunculan(3)=kemunculan(3)/(baris*kolom);

case 4

kemunculan(4)=kemunculan(4)+1;

probkemunculan(4)=kemunculan(4)/(baris*kolom);

case 5

kemunculan(5)=kemunculan(5)+1;

probkemunculan(5)=kemunculan(5)/(baris*kolom);

case 6

kemunculan(6)=kemunculan(6)+1;

probkemunculan(6)=kemunculan(6)/(baris*kolom);

case 7

kemunculan(7)=kemunculan(7)+1;

probkemunculan(7)=kemunculan(7)/(baris*kolom);

case 8

kemunculan(8)=kemunculan(8)+1;

probkemunculan(8)=kemunculan(8)/(baris*kolom);

case 9

kemunculan(9)=kemunculan(9)+1;

probkemunculan(9)=kemunculan(9)/(baris*kolom);

case 10

kemunculan(10)=kemunculan(10)+1;

probkemunculan(10)=kemunculan(10)/(baris*kolom);

case 11

kemunculan(11)=kemunculan(11)+1;

probkemunculan(11)=kemunculan(11)/(baris*kolom);

case 12

kemunculan(12)=kemunculan(12)+1;

probkemunculan(12)=kemunculan(12)/(baris*kolom);

case 13

kemunculan(13)=kemunculan(13)+1;

probkemunculan(13)=kemunculan(13)/(baris*kolom);

case 14

kemunculan(14)=kemunculan(14)+1;

probkemunculan(14)=kemunculan(14)/(baris*kolom);

otherwise

kemunculan(15)=kemunculan(15)+1;

probkemunculan(15)=kemunculan(15)/(baris*kolom);

end

end

end

kemunculan

probkemunculan

 

for i=1:derajatkeabuan

if i==1

sumprobkemunculan(i)=probkemunculan(i);

else

sumprobkemunculan(i)=sumprobkemunculan(i-1)+probkemunculan(i);

end

end

sumprobkemunculan

 

for i=1:derajatkeabuan

sumprobkemunculan(i)=sumprobkemunculan(i)*derajatkeabuan;

end

 

for i=1:baris;

for j=1:kolom;

switch awal(i,j)

    case 0

akhir(i,j)=ceil(sumprobkemunculan(0));
case 1

akhir(i,j)=ceil(sumprobkemunculan(1));

case 2

akhir(i,j)=ceil(sumprobkemunculan(2));

case 3

akhir(i,j)=ceil(sumprobkemunculan(3));

case 4

akhir(i,j)=ceil(sumprobkemunculan(4));

case 5

akhir(i,j)=ceil(sumprobkemunculan(5));

case 6

akhir(i,j)=ceil(sumprobkemunculan(6));

case 7

akhir(i,j)=ceil(sumprobkemunculan(7));

case 8

akhir(i,j)=ceil(sumprobkemunculan(8));

case 9

akhir(i,j)=ceil(sumprobkemunculan(9));

case 10

akhir(i,j)=ceil(sumprobkemunculan(10));

case 11

akhir(i,j)=ceil(sumprobkemunculan(11));

case 12

akhir(i,j)=ceil(sumprobkemunculan(12));

case 13

akhir(i,j)=ceil(sumprobkemunculan(13));

case 14

akhir(i,j)=ceil(sumprobkemunculan(14));

otherwise

akhir(i,j)=ceil(sumprobkemunculan(15));

end

end

end

akhir
Previous
Next Post »