please explain function [dum,z]

6 ビュー (過去 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 Center および File ExchangeNumber Theory についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by