필터 지우기
필터 지우기

Find the greater number in a matrix

조회 수: 2 (최근 30일)
barath manoharan
barath manoharan 2022년 12월 20일
답변: Dyuman Joshi 2022년 12월 20일
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