WHY EVERY TIME I AM GETTING THE ERROR "Cell contents assignment to a non-cell array object." I need to store the value of "ISG" which is a one dimensional array(array elements changes for every i,j) into every cell of "VarIsg" .. PLEASE HELP ME OUT

조회 수: 2 (최근 30일)
for i=1:3
for j=1:3
mat_cor= InsideSquareCoordinate2{i,j};
mat_data=InsideSquareGrade2{i,j};
mat_data=mat_data(mat_data~=0);
mat_dl=length(mat_data);
%%%%%%%%%%%****-----------------------------------------------------------------------------------------****%
% mat_data(:,n1)
% n1=1;
% if ~isempty (InsideSquareCoordinate2{i,j})
VarIsg=0;
tempPointCord=InsideSquareCoordinate2{i,j};
xCordInside=tempPointCord(:,1);
yCordInside=tempPointCord(:,2);
for i1=1:mat_dl
for j1=1:mat_dl
if (i1~=j1)
d=sqrt((xCordInside(i1)-xCordInside(j1))^2 + (yCordInside(i1)-yCordInside(j1))^2);
if((xCordInside(j1)-yCordInside(i1))==0)
theta=90;
else
theta=180.*atan((yCordInside(j1)-yCordInside(i1))./(xCordInside(j1)-yCordInside(i1)))./pi;
end
minlag=10; nlag=3; laginv=10; clear('ISG')
for k=1:nlag
llag(k)=minlag+(k-1)*laginv;
hlag(k)=llag(k)+laginv;
b=abs(d.*sin(theta-azm));
if((llag(k)<=d && d<hlag(k))&&(lowangle<=theta &&theta<upangle)&&(b<=maxbandw))
ISG(k)= sum((mat_data(i1)- mat_data(j1)).^2)/(2*mat_dl);
end
end
ISG
VarIsg{i,j}=ISG
end
end
end
% ISG
% VarIsg{i,j}=0;
end
end

채택된 답변

Walter Roberson
Walter Roberson 2018년 7월 20일
You have
VarIsg=0;
so VarIsg is numeric.
Later you do
VarIsg{i,j}=ISG
which attempts to access VarIsg as if it is a cell array. But it is not a cell array, it is numeric.
Your line
VarIsg=0;
should probably be
VarIsg{i,j} = 0;

추가 답변 (1개)

RAJ DATTA
RAJ DATTA 2018년 7월 29일
thank u all for your valuable replies...it works..

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by