【问题标题】:Matlab: Repmat and orthogonal vectorsMatlab:Repmat 和正交向量
【发布时间】:2011-11-23 18:34:37
【问题描述】:

我有三个正交的向量

   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

【问题讨论】:

    标签: matlab multidimensional-array vectorization orthogonal


    【解决方案1】:

    我认为你应该这样做:

    b_vect = reshape([1 2],[1 1 numel(b_vect)]);
    

    【讨论】:

    • 确实,我需要的基本上是:b_vect_shape = reshape(b_vect, [1 1 length(b_vect)]) 并在 b_arr 中使用它
    猜你喜欢
    • 1970-01-01
    • 2020-05-19
    • 1970-01-01
    • 2012-08-02
    • 2020-10-23
    • 2019-06-15
    • 2023-04-02
    • 1970-01-01
    相关资源
    最近更新 更多