diagrv.m

来自「计量工具箱」· M 代码 · 共 28 行

M
28
字号
function y = diagrv(x,v)% PURPOSE: replaces main diagonal of a square matrix% -----------------------------------------% USAGE: y - diagrv(x,v)% where: x = input matrix%        v = vector to replace main diagonal% -----------------------------------------% RETURNS: y = matrix x with v placed on main diagonal% -----------------------------------------% NOTE: a Gauss compatability function% -----------------------------------------------------% written by:% James P. LeSage, Dept of Economics% University of Toledo% 2801 W. Bancroft St,% Toledo, OH 43606% jpl@jpl.econ.utoledo.edu  [r,c] = size(x);if r ~= c;  error('x matrix not square')end;if length(v) ~= r;  error('v is not conformable with x')end;y = x - diag(diag(x)) + diag(v);

⌨️ 快捷键说明

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