expd.m

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

M
36
字号
function zx=expd(x,n)
%EXPD   Expand a vector by repeating its points
%       EXPD(X,n) expands the vector X to n times
%       its length by repeating each point in X n times.
%       This utility is used by FCOMP.
%
%       It is also useful for simulating the output of a continuous
%       system which is driven by a sampled data system.
%       Having simulated the closed loop system at the sample times
%       the sampled input to the continuous system is passed through
%       EXPD and then used as the input U to LSIM to simulate the
%       continuous response of the continuous system.
%       The time step for LSIM is Ts/n , the sample time / n.
%       See also COMP

%       Dr M.P. Ford 20th August 1987
% Copyright (c) 1987 by GEC Engineering Research Centre & Cambridge Control Ltd

if (n<=0)|(rem(n,1)~=0)
   error('N not a positive integer');
end
[mx,nx]=size(x);
if min(mx,nx)~=1
   error('Input to be expanded not a vector');
end
if mx==1
   zx=zeros(1,length(x)*n);
else
   zx=zeros(length(x)*n,1);
end
k=0:n:(length(x)-1)*n;
for i=1:n
   zx(k+i)=x;
end

⌨️ 快捷键说明

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