MATLAB: How can i find a special row matrix row How can i find a row which including only -1. In that A matrix how can i write a code A=[-1,-1,0,0,0;0,0,0,-1,0;0,1,-1,0,-1;0,0,1,0,0;1,0,0,1,1] Best Answer You could tryblnA = logical( A == -1 );blnOut = find( sum( blnA' ) == 1 );variable 'blnA' finds the elements of matrix A, which are equal to -1.The output of blnA isblnA = 1 1 0 0 0 0 0 0 1 0 0 0 1 0 1 0 0 0 0 0 0 1 0 0 0if there is just one '-1', the summary for each row of logical matrix blnA will be '1'.And because the command 'sum' sums the elements of column.So need to do a transpose.The output of blnOutblnOut = 2A ha, row 2. Got it. Related SolutionsMATLAB: Find a row with -1 blnOut = find(all(ismember(A,[0,-1]),2)); MATLAB: Finding matrix column index based on certain conditions result = find(sum(A==1)==1 & sum(A==0)==(size(A,1)-1)); Related QuestionHow can i find column refer to rowHow to find the index of any value in array (during for loop)How can i choose one result of numerical resultFind the index of the rows that have all 1Get result from uitable’s row numberHow to delete column with one number onlyConvert matrix to UitableHow to find Place on non zero values in matrix
Best Answer