t2w.m

来自「包含大量遗传算法程序」· M 代码 · 共 40 行

M
40
字号
function [w,t] = t2w(range,dt)
%T2W     Forms frequency vector for use with fimpulse and fstep.
%
%        [w,t] = t2w(range,dt)
%        [w,t] = t2w(range)
%            w = t2w(range,dt)
%            w = t2w(range)
%
% Forms frequency vector w for use with fimpulse and fstep, given
% the simulation range (time horizon), and the required resolution dt.
% The default resolution is range/1024.
% The second (optional) output argument is the vector
% of time points, which is useful when plotting time responses.
% The number of points in w is always (N/2)+1, where N is a 
% power of 2. The achieved resolution may be greater than that
% required.

% J.M.Maciejowski, 13 March 1988. Revised 1 June 1988, JMM.
% Copyright (C) Cambridge Control Ltd, 1988.

nargi = nargin; nargo = nargout;
nargchk(1,2,nargi);
nargchk(1,2,nargo);
if range<=0, 
  error('Range must be positive. (T2W)')
end

N = 1024; % Default
if nargi > 1,
  N = range/dt;
  N = 2^ceil(log(N)/log(2));
end

w = (0:2:N)*pi/range;

if nargo > 1,
  dt = range/(N-1);
  t = 0:dt:range; 
end

⌨️ 快捷键说明

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