getting error in for loop
이전 댓글 표시
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
2022년 5월 30일
Have you checked if your array indices are positive integers or logical values?
답변 (2개)
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
2022년 5월 30일
0 개 추천
댓글 수: 7
Nudrat Sufiyan
2022년 5월 30일
Torsten
2022년 5월 30일
The code works fine for me.
Nudrat Sufiyan
2022년 5월 30일
Torsten
2022년 5월 30일
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
2022년 5월 30일
Torsten
2022년 5월 30일
@Nudrat Sufiyan comment moved here
It means I should change the value of r2
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!