How to calculate threshold for matrix in Matlab?

I wrote these codes to calculate a threshold for distance values between features of the dataset. after computing hamming distance (a) between columns of the dataset, I defined z value, when the distance between two features is more than z, (for example feature ith and jth) so the threshold is between i and j, and we can select the features based on this threshold and remove the rest of the features. At the end, I used fprintf to show the ith and jth features in the output.
I'll be very grateful to have your opinions how to improve the program to compute the threshold for selecting features. Thanks
close all;
clc
load lung.mat
data=lung;
[n,m]=size(data);
l=1;
t=1;
data1=[];
data2=[];
if data(i,m)==1
data1(l,:)=data(i,:);
l=l+1;
else
data2(t,:)=data(i,:);
t=t+1;
end
end
if t>l
data1(l:t-1,:)=0;
else
data2(t:l-1,:)=0;
end
for i=1: m
thisCol1=data1(:,i);
thisCol2=data2(:,i);
a(i)=fHammingDist(thisCol1,thisCol2);
z=sum(a)/m;
if abs(a(i)-a(j))> z
fprintf(' threshold is between %10.6f and %10.6f ',i,j);
end
end
end
but there is an error for line
if abs(a (i)-a(j)) > z
Subscript indices must either be real positive integers or logicals.

Respuestas (1)

KALYAN ACHARJYA
KALYAN ACHARJYA el 30 de Jul. de 2019
Editada: KALYAN ACHARJYA el 30 de Jul. de 2019
j define?
abs(a(i)-a(j))> z
%..........^
a5?
z=sum(a5)/m;
%.....^

4 comentarios

phdcomputer Eng
phdcomputer Eng el 31 de Jul. de 2019
i and j are counters for passing the array (a). I wanted to compare the values of this array with each other and if the distance between them is more than z so I want to save the indexes of the array ( i and j).
KALYAN ACHARJYA
KALYAN ACHARJYA el 31 de Jul. de 2019
Editada: KALYAN ACHARJYA el 31 de Jul. de 2019
Sir, I am asking have you define j and a5 in the code? When I checked, I didnot get it.
I didn't define j in the code, I don't know how to define the counter for passsing an array.
a5 is a typing mistake I meant a.
a(i)=fHammingDist(thisCol1,thisCol2);
a is an array that includes distances between columns of the dataset.
KALYAN ACHARJYA
KALYAN ACHARJYA el 31 de Jul. de 2019
Editada: KALYAN ACHARJYA el 31 de Jul. de 2019
Please do share
>>whos data
and
>>whos a
Also What does it mean "define the counter for passsing an array"?

Iniciar sesión para comentar.

Categorías

Más información sobre Characters and Strings en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 30 de Jul. de 2019

Editada:

el 31 de Jul. de 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by