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!