下記ページを細かい解説
% Code to plot simulation results from elec_mosfet
%% Plot Description:
%
% The plot below shows drain current vs. drain-source voltage for a range
% of gate voltages.
%
% Copyright 2008-2016 The MathWorks, Inc.
ModelName = get_param(gcb,'Parent');
ParameterBlk = [ModelName '/Parameters'];
Vg_vec = str2num(get_param(ParameterBlk,'Vg_vec'));
Vds_min = str2num(get_param(ParameterBlk,'Vds_min'));
Vds_max = str2num(get_param(ParameterBlk,'Vds_max'));
if Vds_max <= Vds_min
pm_error('physmod:elec:library:InconsistentMaskParameters','Maximum drain-source voltage','Minimum drain-source voltage')
end
t_sim = 1;
clear legend_infoId_matVds_vec
for i=1:length(Vg_vec)
Vg = Vg_vec(i);
legend_info{i} = ['Vg = ',num2str(Vg)]; %#ok<SAGROW>
sim(ModelName,t_sim)
Id_mat(:,i) = Id.signals.values; %#ok<SAGROW>
Vds_vec = Vds.signals.values;
end
% Reuse figure if it exists, else create new figure
if ~exist('h1_elec_mosfet', 'var') || ...
~isgraphics(h1_elec_mosfet, 'figure')
h1_elec_mosfet = figure('Name', 'elec_mosfet');
end
figure(h1_elec_mosfet)
clf(h1_elec_mosfet)
plot(Vds_vec,Id_mat','LineWidth',1)
axis([Vds_min Vds_max max(-30,min(min(Id_mat))) min(30,max(max(Id_mat)))])
xlabel('Drain-Source Voltage (V)')
ylabel('Drain Current (A)')
legend(legend_info);
title('MOSFET Curves: Ic vs. Vds for Varying Gate Voltage')
grid on
% Reset default values
Vg = 5;
Vds_min = 0;
Vds_max = 4;