Matlab:Repmat 和正交向量
我有三个正交的向量
b_vect = [1 2]
L_vect = [10 20 30]
f_vect = [100 200 300]
,我想进行元素对元素的操作。我使用repmat 沿其他维度复制向量,以便获得3D 数组。
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!
然而,由于 b_vect
的方向,这会出错。对于f_arr
,可以采用旋转向量f_vect'$
,但是在b_vect
的情况下应该如何完成?
size(b_arr)
size(L_arr)
size(f_arr)
例如,元素对元素的乘积将是
product = b_arr.*L_arr.*f_arr
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你应该这样做:
I think you should do: