Home > utility > sameValueRow.m

sameValueRow

PURPOSE ^

sameValueRow: Return the index of same-value row in a matrix

SYNOPSIS ^

function rowIndex=sameValueRow(x)

DESCRIPTION ^

 sameValueRow: Return the index of same-value row in a matrix
    Usage: rowIndex=sameValueRow(x)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

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

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