Find the greater number in a matrix

2 visualizaciones (últimos 30 días)
barath manoharan
barath manoharan el 20 de Dic. de 2022
Respondida: Dyuman Joshi el 20 de Dic. de 2022
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]

Respuesta aceptada

Dyuman Joshi
Dyuman Joshi el 20 de Dic. de 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

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by