"Too many input arguments" when calling a constructor with named arguments
Show older comments
Hi,
I have a class which is a subclass of another class.
Superclass:
classdef fet
%FET transistor superclass
% defines a generic FET transistor.
properties
% fet SPICE
LEVEL, % SPICE simulation model
VTO, % threshold voltage with zero Vsb (unit: V)
GAMMA, % body-effect coefficient (unit: V^(1/2))
PHI, % 2*Phi_F i.e. workfunction (unit: V)
NSUB, % NSUB: substrate doping (unit: cm^(−3))
LD, % source/drain side diffusion (unit: m)
UO, % channel mobility (unit: cm^2/V/s)
LAMBDA, % channel-length modulation coefficient (unit: V^(−1))
TOX, % gate-oxide thickness (unit: m)
PB, % source/drain junction built-in potential (unit: V)
CJ, % source/drain bottom-plate junction capacitance per unit area (unit: F/m^2)
CJSW, % source/drain sidewall junction capacitance per unit length (unit: F/m)
MJ, % exponent in CJ equation (unitless)
MJSW, % exponent in CJSW equation (unitless)
CGDO, % gate-drain overlap capacitance per unit width (unit: F/m)
JS, % source/drain leakage current per unit area (unit: A/m^2)
% dimensions
W,
L,
% Oxide capacitance
Cox, % (unit: F/m^2)
% effective channel length
Leff,
% simulation properties
I_drain,
V_gs
V_ds
% device type ('NFET' or 'PFET')
type
% some constants
constants;
end
methods
function obj = fet(LEVEL, VTO, GAMMA, PHI, NSUB, LD, UO, LAMBDA, TOX, PB, CJ, CJSW, MJ, MJSW, CGDO, JS, W, L, type)
%Constructor
% constructs device parameters
constants = semiConstants;
obj.LEVEL = LEVEL;
obj.VTO = VTO;
obj.GAMMA = GAMMA;
obj.PHI = PHI;
obj.NSUB = NSUB;
obj.LD = LD;
obj.UO = UO;
obj.LAMBDA = LAMBDA;
obj.TOX = TOX;
obj.PB = PB;
obj.CJ = CJ;
obj.CJSW = CJSW;
obj.MJ = MJ;
obj.MJSW = MJSW;
obj.CGDO = CGDO;
obj.JS = JS;
obj.W = W;
obj.L = L;
obj.type = type;
obj.Cox = constants.epsilon_r_Si*constants.epsilon_0/obj.TOX;
obj.Leff = L-2*LD;
end
function outputArg = method1(obj,inputArg)
%METHOD1 Summary of this method goes here
% Detailed explanation goes here
outputArg = obj.Property1 + inputArg;
end
end
% % abstract functions
% methods (Abstract)
% Id_sat(obj)
% end
end
Subclass:
classdef nfet < fet
%NFET Summary of this class goes here
% Detailed explanation goes here
properties
end
methods
function obj = nfet(LEVEL, VTO, GAMMA, PHI, NSUB, LD, UO, LAMBDA, TOX, PB, CJ, CJSW, MJ, MJSW, CGDO, JS, W, L)
%NFET Constructor
% Constructs NFET
obj = obj@fet(LEVEL, VTO, GAMMA, PHI, NSUB, LD, UO, LAMBDA, TOX, PB, CJ, CJSW, MJ, MJSW, CGDO, JS, W, L, 'NFET');
end
function Id_sat(obj)
%METHOD1 computes drain current
obj.Id = 1/2*(UO*10^-4)*(obj.Cox)*(obj.W/obj.Leff)*(V_gs-VTO)^2*(1+(LAMBDA)*V_ds);
end
% function outputArg = method1(obj,inputArg)
% %METHOD1 Summary of this method goes here
% % Detailed explanation goes here
% outputArg = obj.Property1 + inputArg;
% end
end
end
When I call liket this:
nfet(1, 0.7, 0.45, 0.9, 9e14, 0.08e-6, 350, 0.1, 9e-9, 0.9, 0.56e-3, 0.35e-11, 0.45, 0.2, 0.4e-9, 1.0e-8, 50e-6, 0.5e-6)
It's all fine!
BUT, if I call like this:
nfet(LEVEL=1, VTO=0.7, GAMMA=0.45, PHI=0.9, NSUB=9e14, LD=0.08e-6, UO=350, LAMBDA=0.1, TOX=9e-9, PB=0.9, CJ=0.56e-3, CJSW=0.35e-11, MJ=0.45, MJSW=0.2, CGDO=0.4e-9, JS=1.0e-8, W=50e-6, L=0.5e-6)
I get an error:
Error using nfet
Too many input arguments.
What's going on? How to fix this? I want to call with names because if I want to change the value, I don't want to fiddle thru 18 arguments.
Accepted Answer
More Answers (1)
Note the attached utility copyprops().
function obj = fet(varargin)
constants = semiConstants;
obj=copyprops(struct(varargin{:}),obj);
obj.Cox = constants.epsilon_r_Si*constants.epsilon_0/obj.TOX;
obj.Leff = obj.L-2*obj.LD;
end
function obj = nfet(varargin)
%NFET Constructor
% Constructs NFET
obj = obj@fet(type='NFET',varargin{:});
end
Categories
Find more on Function Creation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!