Error using plot Vectors must be the same length.

1 view (last 30 days)
iicecont
iicecont on 23 Feb 2021
Answered: Jan on 25 Feb 2021
I'm trying to plot ID VDS characteristics for my designed mosfet but after i try to run the code it shows "Error using plot Vectors must be the same length.".
here is my code, thanks in advance
clc; clear all; close all;
%parameters and define variable
syms x y;
un = 17215.771;
Kox = 4.2;
ep0 = 8.854e-12;
x0 = 50e-9;
Cox = ((Kox*ep0)/x0);
VTH = 0.5;
VGS = 2; % [V]
eqna = 20.10364e-6 == 0.5 * un * Cox * (y) * ((VGS - VTH).^2)*(1 + (x * 3.75));
eqnb = 20.34537e-6 == 0.5 * un * Cox * (y) * ((VGS - VTH).^2)*(1 + (x * 4));
eqns = [eqna eqnb];
S = solve(eqns, [x y]);
x = S.x;
y = S.y;
figure(3);
Vgs = (1:0.5:5);
Vds = (0:0.25:5);
[sz1,sz2] = size(Vgs);
for t = (sz1:sz2)
VDSAT2 = Vgs - VTH;
VDSS = (0:0.25:VDSAT2(t));
VDSS2 = Vgs(t) - VTH + 0.25:0.25:5;
IDLinear = un.*Cox.*y.*(((VDSAT2(t)).*VDSS)-((VDSS.^2)/2));
IDSat = 0.5.*un.*Cox.*y.*((VDSAT2(t)).^2).*(1+x.*(VDSS2));
[u,v] = size(VDSS);
[uu,vv] = size(Vds);
for q = (1:v)
ID(t,q) = IDLinear(1,q);
end
for r = (v+1:vv)
IDD(t,r) = IDSat(1,r-v);
end
plot(VDSS,ID,[VDSS2 5],[IDD IDD]);
hold on
end

Answers (1)

Jan
Jan on 25 Feb 2021
Use the debugger to find the cause of the problem. Type in the command line:
dbstop if error
Run the code again. If it stops, check the sizes of the arguments provided to plot:
size(VDSS)
size(ID)
size([VDSS2 5])
size([IDD IDD])
Something is not matching. Which one?

Categories

Find more on Polar Plots in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!