查看单个帖子
旧 2019-11-25, 20:00   #1
poster
高级会员
 
注册日期: 2019-11-21
帖子: 3,006
声望力: 66
poster 正向着好的方向发展
默认 how to solve this error: "Subscript indices must either be real positive integers or logicals"?

I wrote this program for computing the average of the distance between each feature and the rest of the features in the colon dataset. I defined a function for computing Chebyshev distance.



close all;
clc
load colon.mat
data=colon;
[n,m]=size(data);
for i=1:m-1
for j=i+1:m
t(i,j)=fChebyshevDist(data(:,i),data(:,j));
b=sum(t)/(m-1);
end
end


function [ fchd ] = fChebyshevDist(p,q)
fchd=max(abs(p-q));
end


I found this error "Subscript indices must either be real positive integers or logicals" for this line:



 t(i,j)=fChebyshevDist(data(:,i),data(:,j));


that I really haven't got any idea to solve. I'll be very grateful to have your opinions. Thanks





More answer...
poster 当前离线   回复时引用此帖