我在MATLAB中编写了这段代码
close all;
clc
load colon.mat
data=colon;
[n,m]=size(data);
for i=1:m-1
for j=i+1:m
t2(i,j)=fCanberraDist(data(:,i),data(:,j));
b2=sum(t2)/(m-1);
end
end
fCanberraDist是用于计算数据集要素之间的堪培拉距离测度公式的函数。这是函数的代码
function [ fcd ] = fCanberraDist( p,q )
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
a=abs(p-q);
b=p+q;
s=0;
for i=1:size(p,1)
if a(i)~=0 && b(i)~=0
s=s+(a(i)/b(i));
end
end
fcd=s;
程序显示此错误:
Subscript indices must either be real positive integers or logicals.
Error in line:
b2=sum(t2)/(m-1)
对于您如何解决此错误,请多多指教。