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

后端 未结 5 1169
傲寒
傲寒 2021-01-20 17:37

I just started matlab and need to finish this program really fast, so I don\'t have time to go through all the tutorials.

can someone familiar with it please explain

5条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-20 18:23

    note the apparent wrinkle in the matlab convention; there are a number of builtin functions which have signature like:

    xs = sum(x,dim)
    

    which works 'along' the dimension dim. max and min are the oddbal exceptions:

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

    I sometimes wish matlab had a binary max and a collapsing max, instead of shoving them into the same function...

提交回复
热议问题