accumulate.m
来自「计量工具箱」· M 代码 · 共 33 行
M
33 行
function result = accumulate(x)% PURPOSE: accumulates column elements of a matrix x%---------------------------------------------------% USAGE: result = accumulate(x)% where: x = an nobs x nvar matrix or vector%---------------------------------------------------% RETURNS:% results = nobs x nvar matrix containing cumulative sums% of the column elements of the matrix argument x %--------------------------------------------------% written by:% James P. LeSage, Dept of Economics% University of Toledo% 2801 W. Bancroft St,% Toledo, OH 43606% jpl@jpl.econ.utoledo.eduif (nargin ~= 1)error('Wrong number of arguments to accumulate');end;[nobs nvar] = size(x);result = zeros(nobs,nvar);for j=2:nobs;for i=1:nvar;result(1,i) = x(1,i);result(j,i) = result(j-1,i) + x(j,i);end;end;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?