Info
此问题已关闭。 请重新打开它进行编辑或回答。
Programme is not giving any output
1 次查看(过去 30 天)
显示 更早的评论
for i=1:size(X,1)
t1=abs(centroids(1,1)-X(i,1));
t2=abs(centroids(2,1)-X(i,1));
T(i,:)=[t1 t2];
MINM(i,1)=min(T(i,:));
if MINM(i,1)==T(i,1)
Sample(i,1)=1;
else
Sample(i,1)=2;
end
end
Location=find(Sample==1);
this programme is not giving any output and even errors also.. up to 1hr also it is not giving any output.
Kindly help me to resolve this.
2 个评论
Walter Roberson
2019-2-19
try pressing control C. I suspect it might be expecting you to type something .
回答(1 个)
KSSV
2019-2-19
I suspect, you are using == on flottants...try the below code.
tol = 10^-6 ;
for i=1:size(X,1)
t1=abs(centroids(1,1)-X(i,1));
t2=abs(centroids(2,1)-X(i,1));
T(i,:)=[t1 t2];
MINM(i,1)=min(T(i,:));
if abs(MINM(i,1)-T(i,1))<=tol
Sample(i,1)=1;
else
Sample(i,1)=2;
end
end
Location=find(Sample==1);
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!