Cell contents reference from a non-cell array object.
显示 更早的评论
clear all;
clc;
%For ceating nodes(Sensor node)
num1 = input('Enter the no of nodes you want to consider in your WSN');
radius = 30;
for i= 1:num1
X = rand(1,num1).*2;
Y = rand(1,num1).*3;
end
X
Y
%Calculate Distance
for i= 1:num1
for j= i+1 : num1
dist= sqrt((X{i}-X{j})^2+(Y{i}-Y{j})^2);
% C=dist(i,j);
end
end
disp(C)
I am getting error "Cell contents reference from a non-cell array object" for line dist= sqrt((X{i}-X{j})^2+(Y{i}-Y{j})^2);. Please tell me how to solve this problem.
采纳的回答
更多回答(2 个)
PATRICK WAYNE
2018-2-14
1 个投票
I've received this error using cell2mat. For instance, I'll have a P = 1 x 19 cell array where each cell holds a 600 x 1 double. Using
T = cell2mat(P)
works only when I run the entire m-file (giving me a 600 x 19 matrix). If I try to run it as a section in the code, I get the error. And, this line of code is NOT in any loop. I have no idea why this happens. It caused me to waste a LOT of hours.
类别
在 帮助中心 和 File Exchange 中查找有关 Image Arithmetic 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!