Identify which row has a number which exceeds a number N
3 views (last 30 days)
Show older comments
I have a code which finds the position of the rows having a zero or a duplicate number in any particular row in a matrix A. Here is the code:
b = any(~diff(sort(A,2),1,2),2) | any(z==0,2) ; % locate any zero or repeating number
A=[1 2 0
19 5 6
6 6 7
8 9 3]
Result
b=[1
0
1
0]
My question is how to modify this code for it to identify also any particular row having a number which exceeds a fixed number N.
N=16; % assume Fixed number N=16
A=[1 2 0
19 1 4
6 6 7
8 9 3]
Expected result:
b=[1
1
1
0]
Can you please help me out?
0 Comments
Accepted Answer
Joseph Cheng
on 18 Jun 2015
Edited: Joseph Cheng
on 18 Jun 2015
try
any(A>=N,2)
so I don't know what z is but changing z to A i get the desired answer
any(A>=16,2)|any(~diff(sort(A,2),1,2),2) | any(A==0,2)
More Answers (1)
Andrei Bobrov
on 18 Jun 2015
Edited: Andrei Bobrov
on 19 Jun 2015
any([A > N, A == 0 , ~diff(sort(A,2),[],2)],2)
0 Comments
See Also
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!