From: Steven Lord on 10 May 2010 09:49 "sumeet pushpam" <sahil1806(a)gmail.com> wrote in message news:hs88q5$9ji$1(a)fred.mathworks.com... > by closest i mean nearest. lets take an example.. > > say A= [ 1 2 3 ; 10 11 12; 20 21 22] > a 3x3 matrix and B= [12 10 8], then i should get second row as the result > of my question.sort of element by element comparison in each row. Okay, so again, what do you mean by "closest"? b = [1 1 1]; a = [1 100 10; 2 2 2; 1.1 1.1 2.5] If "closest" means "the minimum of the difference between b and the chosen row of a is smallest among rows of a" then you want row 1. If "closest" means "the maximum of the difference between b and the chosen row of a is smallest among rows of a" then you want row 2. If "closest" means "the sum of squares of the difference between b and the chosen row of a is smallest among rows of a" then you want row 3. So again, what SPECIFICALLY do you mean by "closest"? -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ |