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 ?

 采纳的回答

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
.

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by