Assignment between unlike types is not allowed in matlab structure .pls say something

2 ビュー (過去 30 日間)
Wondimu Bantihun
Wondimu Bantihun 2021 年 7 月 20 日
コメント済み: Jan 2021 年 7 月 20 日
ERROR :Assignment between unlike types is not allowed in matlab structure .pls say something.the code is as follows.
for i2=1:1:n
S2(i2).xd=rand(1,1)*xm;
XR(i2)= S2(i2).xd;
S2(i2).yd=rand(1,1)*ym;
YR(i2)=S2(i2).yd;
S2(i2).type='N';%initially no cluster heads only nodes
S2(i2).id=i2;
keep(i2)=i2;
temp_rnd0=i2;
%random election of normal nodes
if(temp_rnd0>=(x+m)*n+1)
S2(i2).E=Eo;
S2(i2).ENERGY=0;
end
if(temp_rnd0<(x+m)*n+1)&&(temp_rnd0>m*n)
S2(i2).E=Eo*(1+b);
S2(i2).ENERGY=0.5;
end
if(temp_rnd0<m*n+1)
S2(i2).E=Eo*(1+a);
S2(i2).ENERGY=1;
end
end
  2 件のコメント
Jonas
Jonas 2021 年 7 月 20 日
please explain what your variables are (content, size, type) and where exactly the error occurs (which line of your code)
Jan
Jan 2021 年 7 月 20 日
@Wondimu Bantihun: Whenever you mention an error in the forum, attach a copy of the complete error message. This makes it much easier to help.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by