필터 지우기
필터 지우기

I have this command "min(A(:,b),[ ],2)", where A is a matrix and b is one of its columns. How does it works?

조회 수: 1 (최근 30일)
Hi everyone! I have this piece in a code I am trying to understand but I don't know what does it means when "[]" and "2" are added inside the min function. Thank you for your help. :)
  댓글 수: 1
Stephen23
Stephen23 2017년 5월 26일
Why not simply read the min documentation, which tells us all (including you!) how min can be used? You can easily find the min documentation using your favorite internet search engine, and it would have taken less time than joining some internet forum and waiting for some strangers to tell you how min works. (tip: those strangers know how min works because they read the documentation).
The documentation states clearly:
" M = min(A,[],dim) returns the smallest elements along dimension dim. For example, if A is a matrix, then min(A,[],2) is a column vector containing the minimum value of each row."
You might like to read this:

댓글을 달려면 로그인하십시오.

채택된 답변

MathReallyWorks
MathReallyWorks 2017년 5월 26일
Hello Vio,
A = [1.7 1.2 1.5; 1.3 1.6 1.99]
M = min(A,[],2) %This gives minimum along rows
and
A = [1.7 1.2 1.5; 1.3 1.6 1.99]
M = min(A,[],1) %This gives minimum along columns
If you don't use [ ] in your code, it shows a modified matrix with all the elements of A. If any value is greater than n, then it is replaced by n otherwise it is unchanged
n=6;
A = [1.7 1.2 6.5; 1.3 1.6 6.99]
M = min(A,n);
and
n=7;
A = [1.7 1.2 6.5; 1.3 1.6 6.99]
M = min(A,n);
This is something I observed while coding. Just wanted to share. I hope it will be helpful.

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by