plotting the graph, help me~~

1 回表示 (過去 30 日間)
whiyan
whiyan 2020 年 10 月 24 日
回答済み: Alan Stevens 2020 年 10 月 24 日
The above graph is the purpose that i want.
The below is the code and it has errors. Whats the problem? Please suggest the code. Thanks
--------------------------------------------------------------------------------------------------------
W=40;
Vth=0.45;
Leff=0.15;
k=4.255*(10^-4)*(W/Leff);
lambda=25*10^-5;
Vgs=linspace(0,2);
vds=[0.2 1 2];
m=length(Vgs);
for k1 = 1:numel(vgs)
for i=1:m
if vgs(k1) < Vth
current(k1,i)=0;
elseif Vds(i) >= (vgs(k1) - Vth)
current(k1,i)=0.5* k * ((vgs(k1) - Vth).^2);
elseif Vds(i) < (vgs(k1) - Vth)
current(k1,i)= k*((vgs(k1)-Vth)*Vds(i) - 0.5*(Vds(i).^2));
end
end
end
figure
plot(Vgs,current, 'LineWidth',1.5)
------------------------------------------------------------------------------------------------------------------------
error: 'current' undefined near line 1, column 1
error: 'vgs' undefined near line 1, column 1

採用された回答

Alan Stevens
Alan Stevens 2020 年 10 月 24 日
You had a few mismatches between vgs and Vgs. Matlab is case sensitive. Try
W=40;
Vth=0.45;
Leff=0.15;
k=4.255*(10^-4)*(W/Leff);
lambda=25*10^-5;
Vgs=linspace(0,2,5);
Vds=[0.2 1 2];
m=length(Vds);
for k1 = 1:numel(Vgs)
for i=1:m
if Vgs(k1) < Vth
current(k1,i)=0;
elseif Vds(i) >= (Vgs(k1) - Vth)
current(k1,i)=0.5* k * ((Vgs(k1) - Vth).^2);
elseif Vds(i) < (Vgs(k1) - Vth)
current(k1,i)= k*((Vgs(k1)-Vth)*Vds(i) - 0.5*(Vds(i).^2));
end
end
end
figure
plot(Vgs,current, 'LineWidth',1.5)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by