Find the greater number in a matrix

2 views (last 30 days)
I am having 2 4*1 column matrix. one consists of 2-bit binary numbers & other matrix consists of decimal numbers. Now i need to find out the values which are greater than or equal to 0.22 in matrix B and store it in matrix C. again i need to compare resulant position values in matrix c with matrix b position and i need to pick the coressponding element in that position in matrix A. Thank you in advance.
Example:
A = [01 ; 10 ; 11 ; 00 ]
B = [0.234 ; 0.148 ; 0.226 ; 0.118]
Expected output :
C = [0.234 ; 0.226]
D = [01 ; 11]

Accepted Answer

Dyuman Joshi
Dyuman Joshi on 20 Dec 2022
This is a simple case of logical indexing.
A=[01 ; 10 ; 11 ; 00];
B=[0.234 ; 0.148 ; 0.226 ; 0.118];
Z=B>=0.22;
C=B(Z)
C = 2×1
0.2340 0.2260
D=A(Z)
D = 2×1
1 11

More Answers (0)

Categories

Find more on Resizing and Reshaping Matrices in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!