Home > utility > sameValueCol.m

sameValueCol

PURPOSE ^

sameValueCol: Return the index of same-value column in a matrix

SYNOPSIS ^

function colIndex=sameValueCol(x)

DESCRIPTION ^

 sameValueCol: Return the index of same-value column in a matrix
    Usage: colIndex=sameValueCol(x)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function colIndex=sameValueCol(x)
0002 % sameValueCol: Return the index of same-value column in a matrix
0003 %    Usage: colIndex=sameValueCol(x)
0004 
0005 % Roger Jang, 20060818
0006 
0007 if nargin<1, selfdemo; return; end
0008 
0009 colIndex=sum(abs(diff(x)))==0;
0010 
0011 % ====== Self demo
0012 function selfdemo
0013 x=[1 2 3 9 ; 1 5 7 9; 1 8 2 9];
0014 colIndex=feval(mfilename, x);
0015 fprintf('x=\n'); disp(x);
0016 fprintf('colIndex=%s(x) produces\n', mfilename);
0017 fprintf('colIndex=\n'); disp(colIndex);

Generated on Tue 01-Jun-2010 09:50:34 by m2html © 2003