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 ?

 採用された回答

Star Strider
Star Strider 2020 年 7 月 18 日

0 投票

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
.

2 件のコメント

Farah Jwaifel
Farah Jwaifel 2020 年 7 月 18 日
thanx alot
Star Strider
Star Strider 2020 年 7 月 18 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by