传送门:
Matlab中set函数
主函数是cp0702_Gaussian_derivatives.m
子函数是cp0702_analytical_waveforms.m
%
% FUNCTION 7.2 : "cp0702_Gaussian_derivatives"
%
% Analysis of waveforms of the Gaussian pulse and its first
% 15 derivatives
%
% The pulse amplitude is set to 'A'
% 'smp' samples of the Gaussian pulse are considered in
% the time interval 'Tmax - Tmin'
%
% The function receives as input the value of the shape
% factor 'alpha'
%
% The function plots in a 4 x 4 grid the waveform of the
% Gaussian pulse and of its first 15 derivatives for the
% 'alpha' received as input
%
% Programmed by Luca De Nardis
function cp0702_Gaussian_derivatives(alpha)
% -----------------------------------------------
% Step Zero - Input parameters and initialization
% -----------------------------------------------
A = 1; % pulse amplitude [V]
smp = 1024; % number of samples
Tmin = -4e-9; % lower time limit
Tmax = 4e-9; % upper time limit
alpha = 0.714e-9 %我加的部分
t=linspace(Tmin,Tmax,smp); % initialization of the
% time axis
pulse=-A*exp(-2*pi*(t/alpha).^2); % pulse waveform
% definition
pulse=A*exp(-2*pi*(t/alpha).^2);
F=figure(1);
set(F,'Position',[100 120 850 400]);% 窗口位置和大小,参数含义为:xmin,ymin,width,heigh
subplot(4,4,1);% 按4行4列布局,定位到第1子图
PT=plot(t,pulse);% 画图
axis([-2e-9 2e-9 -1 1]);% 坐标轴,xmin,xmax,ymin,ymax
set(gca,'XTick',0);%设置X坐标轴刻度数据点位置
set(gca,'XTickLabel',{});%设置X坐标轴刻度处显示的字符
for i=1:15
% determination of the i-th derivative
derivative(i,:) = ...
cp0702_analytical_waveforms(t,i,alpha);
% 第i个导数的幅度归一化
derivative(i,:) = derivative(i,:) / ...
max(abs(derivative(i,:)));
% -----------------------------------------------
% Step One - Graphical output
% -----------------------------------------------
subplot(4,4,i+1);
PT=plot(t,derivative(i,:));
axis([-2e-9 2e-9 -1 1]);% 坐标轴,xmin,xmax,ymin,ymax
if(i < 12)
set(gca,'XTick',0);
set(gca,'XTickLabel',{});
end
if(i == 2)
set(gca,'XTick',0);
set(gca,'XTickLabel',{'高斯脉冲二阶微分'});
end
if(mod(i,4) ~= 0)
set(gca,'YTickLabel',{});
end
end
h = axes('Position',[0 0 1 1],'Visible','off');
set(gcf,'CurrentAxes',h);
text(.5,0.02,'Time[s]','FontSize',12)
text(0.05,0.4,'Amplitude [V]','FontSize',12,...
'Rotation', 90);
%
% FUNCTION 7.3 : "cp0702_analytical_waveforms"
%
% Definition of the analytical expression for the first 15
% derivatives of the Gaussian pulse
%
% The function receives as input:
% 1) the time axis vector 't'
% 2) the order of the derivative 'k'
% 3) the value of the shape factor 'alpha'
%
% The function returns the vector representing the
% derivative of order 'k' of the Gaussian pulse calculated
% over the time axis 't'
%
% Programmed by Luca De Nardis
function [deriv] = cp0702_analytical_waveforms(t,k,alpha)
switch(k)
case 1
deriv = 4*pi*t/alpha^2.*exp(-2*pi*t.^2/alpha^2);
case 2
deriv = -4*pi*exp(-2*pi*(t.^2)/alpha^2).*...
(-alpha^2+4*pi*(t.^2))/alpha^4;
case 3
deriv = 16*pi^2*t.*exp(-2*pi*(t.^2)/alpha^2).*...
(-3*alpha^2+4*pi*(t.^2))/alpha^6;
case 4
deriv = -16*pi^2*exp(-2*pi*(t.^2)/alpha^2).*...
(3*alpha^4-24*pi*(t.^2)*alpha^2+16*pi^2*...
(t.^4))/alpha^8;
case 5
deriv = 64*pi^3*t.*exp(-2*pi*(t.^2)/alpha^2).*...
(15*alpha^4-40*pi*(t.^2)*alpha^2+16*pi^2*...
(t.^4))/alpha^10;
case 6
deriv = -64*pi^3*exp(-2*pi*(t.^2)/alpha^2).*...
(-15*alpha^6+180*pi*(t.^2)*alpha^4-240*...
pi^2*(t.^4)*alpha^2+64*pi^3*(t.^6))/alpha^12;
case 7
deriv = 256*pi^4*t.*exp(-2*pi*(t.^2)/alpha^2).*...
(-105*alpha^6+420*pi*(t.^2)*alpha^4-336*pi^2*...
(t.^4)*alpha^2+64*pi^3*(t.^6))/alpha^14;
case 8
deriv = -256*pi^4*exp(-2*pi*(t.^2)/alpha^2).*...
(105*alpha^8-1680*pi*(t.^2)*alpha^6+3360*pi^2*...
(t.^4)*alpha^4-1792*pi^3*(t.^6)*alpha^2+...
256*pi^4*(t.^8))/alpha^16;
case 9
deriv = 1024*pi^5*t.*exp(-2*pi*(t.^2)/alpha^2).*...
(945*alpha^8-5040*pi*(t.^2)*alpha^6+6048*pi^2*...
(t.^4)*alpha^4-2304*pi^3*(t.^6)*alpha^2+256*...
pi^4*(t.^8))/alpha^18;
case 10
deriv = -1024*pi^5*exp(-2*pi*(t.^2)/alpha^2).*...
(-945*alpha^10+18900*pi*(t.^2)*alpha^8-50400*...
pi^2*(t.^4)*alpha^6+40320*pi^3*(t.^6)*....
alpha^4-11520*pi^4*(t.^8)*alpha^2+1024*pi^5*...
(t.^10))/alpha^20;
case 11
deriv = 4096*pi^6*t.*exp(-2*pi*(t.^2)/alpha^2).*...
(-10395*alpha^10+69300*pi*(t.^2)*alpha^8-...
110880*pi^2*(t.^4)*alpha^6+63360*pi^3*(t.^6)*...
alpha^4-14080*pi^4*(t.^8)*alpha^2+1024*pi^5*...
(t.^10))/alpha^22;
case 12
deriv = -4096*pi^6*exp(-2*pi*(t.^2)/alpha^2).*...
(10395*alpha^12-249480*pi*(t.^2)*alpha^10+...
831600*pi^2*(t.^4)*alpha^8-887040*pi^3*(t.^6)*...
alpha^6+380160*pi^4*(t.^8)*alpha^4-67584*pi^5*...
(t.^10)*alpha^2+4096*pi^6*(t.^12))/alpha^24;
case 13
deriv = 16384*pi^7*t.*exp(-2*pi*(t.^2)/alpha^2)...
.*(135135*alpha^12-1081080*pi*(t.^2)*alpha^10+...
2162160*pi^2*(t.^4)*alpha^8-1647360*pi^3*...
(t.^6)*alpha^6+549120*pi^4*(t.^8)*alpha^4-...
79872*pi^5*(t.^10)*alpha^2+4096*pi^6*...
(t.^12))/alpha^26;
case 14
deriv = -16384*pi^7*exp(-2*pi*(t.^2)/alpha^2).*...
(-135135*alpha^14+3783780*pi*(t.^2)*alpha^12-...
15135120*pi^2*(t.^4)*alpha^10+20180160*pi^3*...
(t.^6)*alpha^8-11531520*pi^4*(t.^8)*alpha^6+...
3075072*pi^5*(t.^10)*alpha^4-372736*pi^6*...
(t.^12)*alpha^2+16384*pi^7*(t.^14))/alpha^28;
case 15
deriv = 65536*pi^8*t.*exp(-2*pi*(t.^2)/alpha...
^2).*(-2027025*alpha^14+18918900*pi*(t.^2)*...
alpha^12-45405360*pi^2*(t.^4)*alpha^10+...
43243200*pi^3*(t.^6)*alpha^8-19219200*pi^4*...
(t.^8)*alpha^6+4193280*pi^5*(t.^10)*alpha^4-...
430080*pi^6*(t.^12)*alpha^2+16384*pi^7*...
(t.^14))/alpha^30;
end