MATLAB: “Subscripted assignment dimension mismatch.” error matlab

fuzzy c meansupdate membership matrix

Hi,
I do not know why I have "Subscripted assignment dimension mismatch." error at line u(i,j)=1./sum_d;. Below is my coding:
%update U
for i=1:nc
for j=1:o
sum_d=0;
for k=1:nc
sum_d = sum_d + (distance(c(i,:),x(j,:))/distance(c(k,:),x(j,:)))^(2/(m_exponent-1));
end
u(i,j)=1./sum_d;
end
end
Hope to get the solution soon.Thanks.

Best Answer

What size() does distance(c(i,:),x(j,:)) return? If it is not a scalar then you would be doing "/" between two arrays which is possibly not going to return a scalar.