» help linspace
LINSPACE Linearly spaced vector.
LINSPACE(x1, x2) generates a row vector of 100 linearly
equally spaced points between x1 and x2.
LINSPACE(x1, x2, N) generates N points between x1 and
x2.
See also LOGSPACE, :.
%example6p3.m
%commands
used to display funtion i(t)
%this is
an example of MATLAB script or M-file
%must be
stored in a text file with extension ".m”
%the
commands are executed when the name of the M-file is typed at the
%MATLAB
prompt (without the extension)
tau=0.15; %define
time constant
tini=-4*tau; %select
left starting point
tend=10*tau; %define
right end point
tminus=linspace(tini,0,100);
%use
100 points for t<=0
tplus=linspace(0,tend,
250); % and 250 for t>=0
iminus=2*ones(size(tminus));
%define
i for t<=0
iplus=36/8+5/6*exp(-tplus/tau);
%define
i for t>=0
plot(tminus,iminus,'ro',tplus,iplus,'bd'), grid; %basic
plot command specifying
%color and marker
title('VARIATION
OF CURRENT i(t)'), xlabel('time(s)'), ylabel('i(t)(mA)')
legend('prior to
switching',
'after
switching')
axis([-0.5,1.5,1.5,6]);%define
scales for axis [xmin,xmax,ymin,ymax]