how to zero pad a matrix?

4 ビュー (過去 30 日間)
lohith
lohith 2015 年 1 月 2 日
編集済み: Star Strider 2015 年 1 月 2 日
hi,
my input matrix "x" is a 3X1 matrix.
and i'm using it in the formula
r=x^t (t is some value)
but it is asking for a square matrix or a scalar value.
so, how to convert that 3X1 matrix to 3X3 square matrix by padding zeroes.
please suggest, thanks in advance

採用された回答

dpb
dpb 2015 年 1 月 2 日
More than likely you're actually looking for the "dot" operator .^ to return the element-wise values of the vector x I'd venture...but, if you really are intent on turning into an array, simply
[x zeros(length(x),length(x)-1)]^t
is the generic expression (but I still don't think that's what you intend/want).

その他の回答 (1 件)

Star Strider
Star Strider 2015 年 1 月 2 日
編集済み: Star Strider 2015 年 1 月 2 日
You likely need to use element-wise operations:
r=x.^t;
Note the ‘.^’ replacing ‘^’. See the documentation for Array vs. Matrix Operations for details.

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by