Prev: Local Gabor Binary Pattern Vectorization Problem
Next: Chinese to Englisch conversion- Matlab comments
From: Ahmad Alkandri on 1 Jun 2010 19:01 hi what i mean by '' cover '' is to run the for loop and use all the vector values of the variables a, b and y (ie. a = [1 2 3 4 5 6 7 8 9 ] ....b = [ 7 6 5 4 ] . .. . y = [1 2 5 6 7 ] ) so the for loop will cover every possible combination within these variables Ahmad
From: Walter Roberson on 1 Jun 2010 23:27 Ahmad Alkandri wrote: > what i mean by '' cover '' is to run the for loop and use all the vector > values of the variables a, b and y > > (ie. a = [1 2 3 4 5 6 7 8 9 ] ....b = [ 7 6 5 4 ] . .. . y = [1 2 5 6 7 > ] ) > > so the for loop will cover every possible combination within these > variables [A, B, Y] = ndgrid(a, b, y); k = A + B + Y; disp(k(:));
From: Steven Lord on 2 Jun 2010 10:10 "Walter Roberson" <roberson(a)hushmail.com> wrote in message news:vckNn.32763$h57.614(a)newsfe22.iad... > Ahmad Alkandri wrote: > >> what i mean by '' cover '' is to run the for loop and use all the vector >> values of the variables a, b and y >> >> (ie. a = [1 2 3 4 5 6 7 8 9 ] ....b = [ 7 6 5 4 ] . .. . y = [1 2 5 6 >> 7 ] ) >> >> so the for loop will cover every possible combination within these >> variables > > [A, B, Y] = ndgrid(a, b, y); > > k = A + B + Y; > > disp(k(:)); Another approach is to give the three vectors different orientations and then use BSXFUN twice. a = 1:9; b = 7:-1:4; c = [1 2 5 6 7]; ab = bsxfun(@plus, a, b.'); abc = bsxfun(@plus, ab, reshape(c, 1, 1, [])); -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
First
|
Prev
|
Pages: 1 2 Prev: Local Gabor Binary Pattern Vectorization Problem Next: Chinese to Englisch conversion- Matlab comments |