Struct contents reference from a non-struct array object.

I want to create two matrices: x for the even values of H & y for the odd ones
H= magic(35)+ pascal (35);
oc=1; % odd column
or=1; % odd row
ec=1; %even col
er=1; %even row
for i=1:35
for j=1: 35
if mod(H(i.j),2)==1
x(er,ec)=H(i.j);
er=er+1;
ec=ec+1;
else
y(or,oc)=H(i.j);
or=or+1;
oc=oc+1;
end
j=j+1;
end
i=i+1;
end
so after trying my code, it gave me 'Struct contents reference from a non-struct array object.' ,Can anyone tell me where the problem is ?

 Accepted Answer

Use a comma (,), not a period (.):
mod(H(i.j),2)==1
↑ ← HERE
x(er,ec)=H(i.j);
↑ ← AND HERE
and
y(or,oc)=H(i.j);
↑ ← AND HERE
.

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!