MATLAB: What [Y, I] = max (AS, [], 2) ;?

I just started working with Matlab and have to finish this program quickly, so I don’t have time to go through all the tutorials.

can someone know him, please explain what the following statement makes.

[Y,I]=max(AS,[],2);

[]between ASand 2- this is what confuses me. And the maximum value is assigned both Y, and I?

+3
source share
5 answers

C = max(A,[],dim)returns the largest elements of dimension A given by scalar dim. For example, it max(A,[],1)creates maximum values ​​for the first size (rows) A.

, [C, I] = max(...) C (.. ) I.

, ? MATLAB , . .

m = [[1;6;2] [5;8;0] [9;3;5]]
max(m,[],2)
+2

,

C = max(A,[],dim) A, dim. , max(A,[],1) () A.

[C,I] = max(...) A I. , .

, [] max(A,B).

+5

AS - .
AS ( )

+2

This function takes AS and creates a maximum value along the second dimension of AS. It returns the maximum value of "Y" and the index of its "I".

+1
source

note the apparent wrinkle in the matlab convention; There are a number of built-in functions that have a signature of the type:

xs = sum(x,dim)

which works along the dimension dim. max and min - odd exceptions:

xm = max(x,dim);     %this is probably a silent semantical error!
xm = max(x,[],dim);  %this is probably what you want

I sometimes want Matlab to have binary max and max collapse, instead of pasting them into the same function ...

0
source

Source: https://habr.com/ru/post/1721055/


All Articles