I wrote a program.( It indicating this error:Struct contents reference from a non-struct array object.)please help me,where the error is?

clear all;
close all;
Nt=2;
Nr=2;
alpha=1;
Pb=10^-3;
b=2;
B=10000;
No=(7.94*10^-21);
GtGr=3.162;
dij=100;
lambda=0.12^2;
Ml=10;
Nf=0.01;
ptc=47.8*10^-3;
prc=69.8*10^-3;
psyn=50*10^-3;
Ebt=[];
for i=1:length(Nt);
for j=1:length(Nr);
Ebt=((1+alpha)*(Pb/4^(-1/Nt*Nr))*(2^b-1)/b^((1/Nt*Nr)+1)*(7.94*10^-21)*(((4*pi*dij)^2)/GtGr*lambda)*(Ml*Nf)+((Nt*ptc+2*psyn+Nr*prc)/B.b));
end
end
disp(Ebt);

 采纳的回答

The error is in the for loop, where you typed something like
B.b
at the end. I am not sure what you tried to do with it. The compiler will treat B as a struct and try to reach its field b but it will throw an error since B and b are different numeric variables. Please check that.

更多回答(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