p6_16.m

来自「Advanced Engineering Mathematics using M」· M 代码 · 共 34 行

M
34
字号
% P6_16.M Create pulse of arbitrary length%  clearclf% Input Pulse length Tstart=input('Input Tstart of pulse = ')Tend=input('Input Tend of pulse = ')Tfinal=input('Input Final time Tfinal = ')N=input('Number of points in pulse = ')%% Pulse_to_plot - a column vector of length length_t%deltat=(Tend-Tstart)/Nt=[Tstart:deltat:Tfinal];length_t=length(t)for i=1:length_t  if t(i) < Tstart            pulse_to_plot(i) = 0;  elseif (Tstart <= t(i)) & (t(i) <= Tend)        pulse_to_plot(i) = 1;  elseif t(i) > Tend        pulse_to_plot(i) = 0;  endend%pulse_to_plot= (pulse_to_plot)';plot(t,pulse_to_plot,'*')       % Plot the solutiontitle('Plot of Pulse')xlabel('Time')ylabel('Pulse')gridzoom%% Add comments to define the input variables and output.%

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?