MATLAB: How to check whether the strictly positive elements of each row of a matrix are equal matricesmatrixmatrix arraymatrix manipulation How can I check whether the strictly positive elements of each row of a matrix are equal? E.g. if A=[0 1 1 2; 0 1 0 1; 3 0 3 0] I want B=[0;1;1] Best Answer arrayfun( @(jj) (length(unique(A(jj,(A(jj,:)>0)))) == 1),(1:size(A,1)) )returns ans = 0 1 1 Related SolutionsMATLAB: Extract the first negative value in a matrix column Editout=arrayfun(@(x) min([ 0 A(find(A(:,x)<0,1),x)]),1:size(A,2)) MATLAB: Storing multiple matrices from a loop Hi,You need to re-inizialize the temporary matrix DBIBC for each iteration, if not the first iteration makes 2-5 rows 0 and thats all....BIBC = [1 1 1 1 1;0 1 1 1 1;0 0 1 1 0;0 0 0 1 0;0 0 0 0 1] ;N=length(BIBC); for i=1:N DBIBC = BIBC; rw = find(DBIBC(:,i)==0) DBIBC(rw,:)= 0 DBIBC(i) B{i} = DBIBC; end Related QuestionDistance between all elements of row vectorHow to find separate graphsWhat is wrong with the For loopHow to determine if a matrix is positive definite using MATLABSigma Multiple Matrix for LoopHow to correct for loop
Best Answer