# Cell contents reference from a non-cell array object.

80 visualizaciones (últimos 30 días)
priyanka el 7 de Oct. de 2014
Comentada: Regina N el 11 de Feb. de 2019
clear all;
clc;
%For ceating nodes(Sensor node)
num1 = input('Enter the no of nodes you want to consider in your WSN');
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.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Andrew Reibold el 7 de Oct. de 2014
Don't use the curly brackets. That tells Matlab its a cell when its not. It is an array. Write like this
dist= sqrt((X(i)-X(j))^2+(Y(i)-Y(j))^2);
##### 3 comentariosMostrar 1 comentario más antiguoOcultar 1 comentario más antiguo
muhammad illyas abdul muhji el 23 de Abr. de 2018
does it work for image processing as well?
Regina N el 11 de Feb. de 2019
i also have same error in following code in line 13 plot...:
srcFiles = dir('C:\Users\LENOVO\Desktop\Genuine\1\*.png'); % the folder in which ur images exists
Features = cell(length(srcFiles),1) ;
Valid_points =cell(length(srcFiles),1) ;
for i = 1 : length(srcFiles)
filename = strcat('C:\Users\LENOVO\Desktop\Genuine\1\',srcFiles(i).name);
points1 = detectSURFFeatures(I1); hold on;
[features1, interest_points] = extractFeatures(I1, points1);
Features{i} = features1 ;
Valid_points{i} = interest_points ;
figure; imshow(I1);
plot(interest_points{i}.selectStrongest(10),'showOrientation',true);
end
Features;
Valid_points;

Iniciar sesión para comentar.

### Más respuestas (2)

PATRICK WAYNE el 14 de Feb. de 2018
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.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

priyanka el 7 de Oct. de 2014
Thank you.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre WSNs en Help Center y File Exchange.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by