please explain function [dum,z]
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
[dum,z] = min([sq_dist1;sq_dist2],[],1);
0 Commenti
Risposte (1)
Michael Haderlein
il 30 Set 2014
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.
0 Commenti
Vedere anche
Categorie
Scopri di più su Number Theory in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!