用max()函数即可,比如>> r = rand(1,10);>> [maxr,index]=max(r)maxr =0.9649index =10第一个返回参数是最大值,第二个参数是最大值所在的位置(下标)