Prev: Least square fitting
Next: Simulink data export problem
From: Mano Samuel on 22 Apr 2010 03:58 Hello, Lets say I have a matrix, aa = [1 2 0;-1 0 6] aa = 1 2 0 -1 0 6 If check the number of rows of aa , using size(aa,dim) , where dim is 1 size(aa,1) ans = 2 It tells me there are two rows. Fine. Now if I need to find the minimum value along the row dimension, My mind tends to process it such that there are two rows, hence the output value would be the minimum value along each row. so in the first row, 1 2 0, the minimum value is 0 and , in the second row, -1 0 6 the minimum value is -1 . MATLAB however offers, [val,pos] = min(aa,[],1) val = -1 0 0 pos = 2 2 1 I understand the logic behind MATLAB, but why this way ? . Hope someone can help me understand this. Thank you. Mano
From: Yi Cao on 22 Apr 2010 06:16 "Mano Samuel" <manosamuel(a)rediffmail.com> wrote in message <hqovis$afu$1(a)fred.mathworks.com>... > > Hello, > > Lets say I have a matrix, aa = [1 2 0;-1 0 6] > > aa = > > 1 2 0 > -1 0 6 > > If check the number of rows of aa , using size(aa,dim) , where dim is 1 > > size(aa,1) > > ans = > > 2 > > It tells me there are two rows. > > Fine. Now if I need to find the minimum value along the row dimension, > > My mind tends to process it such that there are two rows, hence the output value would be the minimum value along each row. > > so in the first row, 1 2 0, > > the minimum value is 0 and , > > in the second row, -1 0 6 > > the minimum value is -1 . > > MATLAB however offers, > > [val,pos] = min(aa,[],1) > > val = > > -1 0 0 > > > pos = > > 2 2 1 > > I understand the logic behind MATLAB, but why this way ? . Hope someone can help me understand this. Thank you. > > Mano > > Siize(aa,1) means the size of the first dimension, i.e. size of a column. Similarly, min(aa,[],1) is the minimum along the first dimension, which is the column, i.e. the minimum of columns. HTH Yi
|
Pages: 1 Prev: Least square fitting Next: Simulink data export problem |