フィルターのクリア

Hello, I'm trying to plot the I-V curve for a MOSFET, but I get a "Vectors must be the same length" error message. I don't understand why this is the case.

1 回表示 (過去 30 日間)
clear all; close all; clc;
x1 = 0:0.01:0;
y1 = (0).*x1-(1/2).*x1.^2;
x2 = 0:0.01:6;
y2 = (1/2).*0^2;
x3 = 0:0.01:1;
y3 = (1).*x3-(1/2).*x3.^2;
x4 = 1:0.01:6;
y4 = (1/2).*1^2;
x5 = 0:0.01:2;
y5 = (2).*x5-(1/2).*x5.^2;
x6 = 2:0.01:6;
y6 = (1/2).*2^2;
x7 = 0:0.01:3;
y7 = (3).*x7-(1/2).*x7.^2;
x8 = 3:0.01:6;
y8 = (1/2).*3^2;
x9 = 0:0.01:4;
y9 = (4).*x9-(1/2).*x9.^2;
x10 = 4:0.01:6;
y10 = (1/2).*4^2;
x11 = 0:0.01:5;
y11 = (5).*x11-(1/2).*x11.^2;
x12 = 5:0.01:6;
y12 = (1/2).*5^2;
figure; hold on
x_1 = [x1 x2];
y_1 = [y1 y2];
x_2 = [x3 x4];
y_2 = [y3 y4];
x_3 = [x5 x6];
y_3 = [y5 y6];
x_4 = [x7 x8];
y_4 = [y7 y8];
x_5 = [x9 x10];
y_5 = [y9 y10];
x_6 = [x11 x12];
y_6 = [y11 y12];
b1 = plot(x_1,y_1,'yellow'); M1 = "V_G - V_{th} = 0";
b2 = plot(x_2,y_2,'green'); M2 = "V_G - V_{th} = 1";
b3 = plot(x_3,y_3,'blue'); M3 = "V_G - V_{th} = 2";
b4 = plot(x_4,y_4,'red'); M4 = "V_G - V_{th} = 3";
b5 = plot(x_5,y_5,'cyan'); M5 = "V_G - V_{th} = 4";
b6 = plot(x_6,y_6,'magenta'); M6 = "V_G - V_{th} = 5";
xlabel('V_D')
ylabel('I_D/K')
legend([b1,b2,b3,b4,b5,b6], [M1,M2,M3,M4,M5,M6], 'Location', 'SouthWest')

回答 (1 件)

VBBV
VBBV 2021 年 11 月 16 日
clear all; close all; clc;
x1 = 0:0.01:6;
y1 = (0).*x1-(1/2).*x1.^2;
x2 = 0:0.01:6;
y2 = (1/2)*x2.^2;
x3 = 0:0.01:6;
y3 = (1).*x3-(1/2).*x3.^2;
x4 = 0:0.01:6;
y4 = (1/2)*x4.^2;
x5 = 0:0.01:6;
y5 = (2).*x5-(1/2).*x5.^2;
x6 = 0:0.01:6;
y6 = (1/2)*x2.^2;
x7 = 0:0.01:6;
y7 = (3).*x7-(1/2).*x7.^2;
x8 = 0:0.01:6;
y8 = (1/2)*x3.^2;
x9 = 0:0.01:6;
y9 = (4).*x9-(1/2).*x9.^2;
x10 = 0:0.01:6;
y10 = (1/2)*x4.^2;
x11 =0:0.01:6;
y11 = (5).*x11-(1/2).*x11.^2;
x12 = 0:0.01:6;
y12 = (1/2)*x5.^2;
figure; hold on
x_1 = [x1 x2];
y_1 = [y1 y2];
x_2 = [x3 x4];
y_2 = [y3 y4];
x_3 = [x5 x6];
y_3 = [y5 y6];
x_4 = [x7 x8];
y_4 = [y7 y8];
x_5 = [x9 x10];
y_5 = [y9 y10];
x_6 = [x11 x12];
y_6 = [y11 y12];
b1 = plot(x_1,y_1,'yellow'); M1 = "V_G - V_{th} = 0";
b2 = plot(x_2,y_2,'green'); M2 = "V_G - V_{th} = 1";
b3 = plot(x_3,y_3,'blue'); M3 = "V_G - V_{th} = 2";
b4 = plot(x_4,y_4,'red'); M4 = "V_G - V_{th} = 3";
b5 = plot(x_5,y_5,'cyan'); M5 = "V_G - V_{th} = 4";
b6 = plot(x_6,y_6,'magenta'); M6 = "V_G - V_{th} = 5";
xlabel('V_D')
ylabel('I_D/K')
legend([b1,b2,b3,b4,b5,b6], [M1,M2,M3,M4,M5,M6], 'Location', 'SouthWest')
use uniform vector size for xcoordinates. oneway is to use linspace function instead of defiining the specfic intervals of xdata.
  1 件のコメント
Craig Egan Allistair Tan
Craig Egan Allistair Tan 2021 年 11 月 16 日
(x_1,y_1) to (x_6,y_6) are supposed to be piecewise functions. It's why the intervals for the x-values are different. Is there another way I can code this?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSemiconductors and Converters についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by