Effacer les filtres
Effacer les filtres

Find the greater number in a matrix

2 vues (au cours des 30 derniers jours)
barath manoharan
barath manoharan le 20 Déc 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]

Réponse acceptée

Dyuman Joshi
Dyuman Joshi le 20 Déc 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

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by