Question

I have three vectors which are orthogonal

   b_vect = [1 2]
   L_vect = [10 20 30]
   f_vect = [100 200 300]

and I would like to do element-for element-operations. I use repmat to duplicate the vectors along the other dimensions so 3D arrays are obtained.

   b_arr = repmat(b_vect , [length(f_vect), length(L_vect), 1])   % Wrong?!
   L_arr = repmat(L_vect , [length(f_vect), 1, length(b_vect)])   % Good!
   f_arr = repmat(f_vect', [1, length(L_vect), length(b_vect)])  % Good!

This however goes wrong because of the orientation of b_vect. For f_arr it was possible to take the rotated vector f_vect'$, but how should this be done in the case of b_vect?

   size(b_arr)
   size(L_arr)
   size(f_arr)

The element-for-element product would for instance then be

   product = b_arr.*L_arr.*f_arr
Was it helpful?

Solution

I think you should do:

b_vect = reshape([1 2],[1 1 numel(b_vect)]);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top