简体   繁体   中英

How to find minimum value in a particular row in Matlab?

I have a matrix that looks like this:

M = [2 3 4; 2 4 6; 1 5 3]

How do I find the minimum value in each row? For example, I would first want to find the minimum value of the first row? Thanks!

Use min

>> M = [2 3 4; 2 4 6; 1 5 3];
>> X=min(M')

X =

     2     2     1 % row-wise

OR

>> [E,I] = min(M,[],2) ; % E- Elements, I- Index

You also can try M = min(A(n,:)); %where n is the row you want to look at

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM