timeshft.m

来自「王小平《遗传算法——理论、应用与软件实现》随书光盘」· M 代码 · 共 31 行

M
31
字号
function [out]=timeshft(in,d)
%
% Time shift a data matrix
%
% [out]=timeshft(in,d);
%
% out - timeshifted data
% in  - non-shifted data
% d   - matrix of time delays
%

[D L]=size(in);

%
% Find the maximum time delay.
% This defines where the new
% data matrix starts
%
max_delay=max(d);
start_pos=max_delay+1;
new_len=D-start_pos;

out=[];
for i = 1 : L
	s=start_pos-d(i);
	f=s+new_len;
	temp=in(s:f,i);
	out(:,i)=temp;
end

⌨️ 快捷键说明

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