필터 지우기
필터 지우기

please explain function [dum,z]

조회 수: 8 (최근 30일)
Kalai
Kalai 2014년 9월 30일
답변: Michael Haderlein 2014년 9월 30일
[dum,z] = min([sq_dist1;sq_dist2],[],1);

답변 (1개)

Michael Haderlein
Michael Haderlein 2014년 9월 30일
from the Matlab help:
C = min(A,[],dim)
[C,I] = min(...)
So, [sq_dist1;sq_dst2] is an array (most likely 2-dimensional) whose minimum will be searched.
[] is required as otherwise the array will be compared with the value of this parameter:
min(3,2) -> 2
1 is the dimension along which the minimum values are searched. To understand, just check the difference between
min(magic(3),[],1)
and
min(magic(3),[],2)
That should make it clear.
[dum,z] are the values which are returned. In this case, I suppose dum stands for dummy which means you are actually not interested in this variable, but you need it to get the second parameter. Note that in later releases, you can also use [~,z] which is little more memory efficient. z indicates the indices at which the minimum values are found.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by