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