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일

0 개 추천

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일

0 개 추천

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

Nudrat Sufiyan
Nudrat Sufiyan 2022년 5월 30일
As, I want to plot Idsat and Vds curve.
Torsten
Torsten 2022년 5월 30일
The code works fine for me.
Nudrat Sufiyan
Nudrat Sufiyan 2022년 5월 30일
for me it's showing an horizontal line. Can you please send the output
r1 = 5.420307692307692e-26
Vgs = -2
r2 = -7.731499999999999e+18
Thus Vds won't change anything if you have in mind how large r2 is.
Nudrat Sufiyan
Nudrat Sufiyan 2022년 5월 30일
As vds must varies with Ids. For this what I need to change in the code.
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

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

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2022년 5월 30일

댓글:

2022년 5월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by