elimcol.m

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

M
30
字号
%                                elimcol.m
%  Scope:   This MATLAB macro eliminates a specific column of a given two
%           dimensional matrix.
%  Usage:   y = elimcol(x,k)
%  Description of parameters:
%           x   -  input, initial two dimensional matrix
%           k   -  input, index of the column 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 = elimcol(x,k)

[xrow,xcol] = size(x);
if  (xcol < 2) | (k < 1) | (k > xcol) 
   disp('Error - ELIMCOL ; check dimension or range of index k');
   disp('  ');
   return
end
if  k == 1                     %  eliminate first column
   y = x(:,2:xcol);
elseif  k == xcol              %  eliminate last column 
   xcolm1 = xcol - 1;
   y = x(:,1:xcolm1);
else
   km1 = k - 1;
   kp1 = k + 1;
   y = [x(:,1:km1)  x(:,kp1:xcol)];
end

⌨️ 快捷键说明

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