elimrow.m

来自「GPS software toolbox for GPS receiver de」· M 代码 · 共 30 行

M
30
字号
%                                elimrow.m
%  Scope:   This MATLAB macro eliminates a specific row of a given two
%           dimensional matrix.
%  Usage:   y = elimrow(x,k)
%  Description of parameters:
%           x   -  input, initial two dimensional matrix
%           k   -  input, index of the row to be eliminated from the matrix  x
%           y   -  output, resultant matrix
%  Last update:  06/26/00
%  Copyright (C) 1996-00 by LL Consulting. All Rights Reserved.

function  y = elimrow(x,k)

[xrow,xcol] = size(x);
if  (xrow < 2) | (k < 1) | (k > xrow) 
   disp('Error - ELIMROW; check dimension or range of index k');
   disp('  ');
   return
end

if  k == 1                        %  eliminate first row
   y = x(2:xrow,:);
elseif  k == xrow                 %  eliminate last row
   xrowm1 = xrow - 1;
   y = x(1:xrowm1,:);
else
   km1 = k - 1;
   kp1 = k + 1;
   y = [x(1:km1,:)'  x(kp1:xrow,:)']';
end

⌨️ 快捷键说明

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