matrix question (finding the smallest number in each row)

조회 수: 2 (최근 30일)
Mate 2u
Mate 2u 2012년 10월 15일
I have a matrix B, of size 1455x2. I want a matrix C of size 1455x2 which gives me the matrix B but, if there is a non-negative row, it should be a row of zeros.
Then once I have this C, I want a matrix D which gives me the location of the minimum in each row of C.

채택된 답변

Björn
Björn 2012년 10월 15일
[~,min_col]=min(B,[],2)
This gives you a 1455x1 vector with the column-number of the smallest element in in the rows. To also get the minimum values of each row, you can replace '~' with a variable that you want to assign to those values.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by