deltax.m

来自「wang xiao ping 版遗传算法」· M 代码 · 共 35 行

M
35
字号
function y=deltax(x);
%
%	DELTAX(X)
%	
%	Function to return the difference between
%	successive row elements of an array. First
%	element of result array is zero.
%
%   Differs from MATLAB supplied DIFF function.
%   The DIFF function returns an output vector which
%   is one dimension less thant the input vector.
%   Using DELTAX, the dimension of the output vector/matrix
%   is the same as that of the input vector/matrix.
%
%	Called: y = deltax(x)
%
%	    where   x = an vector/matrix to be processed
%
%   Returns:
%
%           	y = [0, x(2)-x(1), x(3)-x(2), ..., x(n)-x(n-1)]
%
%	M.T. Tham (March 1996)
%


[rows,cols]=size(x);
y=zeros(size(x));

i=2:rows;

y(i,:)=x(i,:)-x(i-1,:);


⌨️ 快捷键说明

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