Extract specific values and row coloumn information in matrix
    4 views (last 30 days)
  
       Show older comments
    
    Fadhurrahman
 on 31 Jan 2022
  
    
    
    
    
    Commented: Star Strider
      
      
 on 31 Jan 2022
            i have a matrix with size of 270x560 and has a value from 0 to 7 in it.
i want to extract a values of 5 in this matrix and also an information about the location (row and column) of these value in 270x560 matrix
is there any reference to do it? 
here is some code that i already tried
x = B(:,:) ;
y = B(:,:) ;
z = x(y==5)
 also i tried using find function but the result shows some random numbers
out = find(B == 5);
0 Comments
Accepted Answer
  Cris LaPierre
    
      
 on 31 Jan 2022
        Use this syntax: [row,col] = find(___)
[row,col] = find(B == 5);
0 Comments
More Answers (1)
  Star Strider
      
      
 on 31 Jan 2022
        Try this — 
M = randi([0 7], 5, 6)                                      % Example Matrix
[r,c] = find(M == 5);                                       % r = Row,  c = Column, For Each Occurrence
row_col = [r c]                                             % Matching Row, Column References
.
See Also
Categories
				Find more on Deep Learning Toolbox 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!

