Find the greater number in a matrix

2 次查看(过去 30 天)
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]

采纳的回答

Dyuman Joshi
Dyuman Joshi 2022-12-20
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by