Suppose we have a vector like
x = -1:0.05:1; ids = randperm(length(x)); x = x(ids(1:20));
I would like to calculate the maximum distance between elements in xsome idiomatic way. It would just be easy to sort through all possible combinations of elements x, but I feel that there may be a way to do this using the MATLAB built-in functions in some crazy but idiomatic way.
x
What about
max_dist = max(x) - min(x)
?
Do you mean the difference between the largest and smallest elements in your vector? If so, something like this will work:
max(x) - min(x)
, .
, , . , , , . , , , , . , , x , :
xmin = min(x); xmax = max(x); maxdistance = max(x - xmin,xmax - x);
, (IPDM). , 1- . :
D = ipdm(x,'subset','farthest','result','struct');
, , , , .
Uhh ... I would like to have MATLAB in my hands and still early in the morning, but what about something like:
max_dist = max(x(2:end) - x(1:end-1));
I do not know, this is what you are looking for.
Source: https://habr.com/ru/post/1737101/More articles:Makefile rule depending on changes in the number / headers of files instead of changing the contents of files - makefileperformance problem in a single table select query - sqlкак moodle сохранять ответ пользовательской викторины в базе данных? - phphttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1737099/how-to-instal-in-svn-repository-on-local-machine&usg=ALkJrhghK8Rr2-ynDuuo6S-tldNiwrwzzAHyphen and the differences between Firefox and other browsers - htmlexecution of records with null values - nullRefresh ListView if I changed the contents of ListItem - androidhow caching is implemented using PHP GD - phpRequired Method Documentation - language-agnosticDeveloping workflows for WF4 in Silverlight - c #All Articles