필터 지우기
필터 지우기

getting error in for loop

조회 수: 3 (최근 30일)
Nudrat Sufiyan
Nudrat Sufiyan 2022년 5월 30일
댓글: Torsten 2022년 5월 30일
Array indices must be positive integers or logical values.
Error in Untitled4 (line 27)
Idsat(i)=r1*(Vgs-(r2)+Vds(i));
for i=0:length(Vds)
Idsat(i)=r1*(Vgs-(r2)+Vds(i));
end
  댓글 수: 1
Sam Chak
Sam Chak 2022년 5월 30일
Have you checked if your array indices are positive integers or logical values?

댓글을 달려면 로그인하십시오.

답변 (2개)

Torsten
Torsten 2022년 5월 30일
편집: Torsten 2022년 5월 30일
Loop indices don't start at 0, but at 1 in MATLAB:
for i=1:length(Vds)
Idsat(i)=r1*(Vgs-(r2)+Vds(i));
end
instead of
for i=0:length(Vds)
Idsat(i)=r1*(Vgs-(r2)+Vds(i));
end

Nudrat Sufiyan
Nudrat Sufiyan 2022년 5월 30일
Thanks , but it still showing error.
can you please check my code once
clc;
m=0.23; %#1%
q=1.6e-19;
Nd=5e18;
d1=22e-7;
d2=1e-7;
a0=3.189e-8;
a1=(-0.077*m+3.189)*1e-8;
c13=(5*m+103);
c33=(-32*m+405);
e33=(0.72*m+0.73)*1e-4;
e31=(-0.11*m-0.49)*1e-4;
fis=1.4*m+0.87;
deff=23.01e-7;
detaEg=6.13*m+(1-m)*3.42-m*(1-m)+(m-1)*3.42;
detaEc=0.7*detaEg;
EA=(8.9-0.4*m)*8.85e-14;
Eoff=EA+((e33)^2)/c33;
EF=2.1;
sigema=((-m*(5.2e-6))+(2*(a0-a1)/a1)*(e31-e33*c13/c33)*1e-4);
Ppz=(2*(a0-a1)/a1)*(e31-e33*c13/c33)*1e-4;
r1=q*EA/deff;
r2=fis-(EF-(detaEc+q^2/EA*sigema^2*d2))/q;
Vgs=-2;
Vds=0:0.01:0.8;
for i=1:length(Vds)
Idsat(i)=r1*(Vgs-(r2)+Vds(i));
end
xlabel('vds');
ylabel('Idsat');
plot(Vds,Idsat)
  댓글 수: 7
Torsten
Torsten 2022년 5월 30일
편집: Torsten 2022년 5월 30일
It varies, but you don't see it in the plot since r2 = -7.731499999999999e+18.
Do you understand what I mean ?
If you plot a variable
T = 100000000 + 0:0.01:0.8
you won't see the 0:0.01:0.8.
Torsten
Torsten 2022년 5월 30일
@Nudrat Sufiyan comment moved here
It means I should change the value of r2

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by