フィルターのクリア

Matrix dimensions must agree when using .*

3 ビュー (過去 30 日間)
Amy Phan
Amy Phan 2017 年 5 月 21 日
コメント済み: Niladri Halder 2022 年 8 月 9 日
Hi all,
I've been trying to multiply two matrices together and I can not find where I went wrong. I'm trying to multiply the matrix and it's transpose together however I am getting the error, "Matrix dimensions must agree."
The two matrices contain the following information:
Name Size Bytes Class Attributes
D_tranpose 6x16384 98304 uint8
D 16384x6 98304 uint8
Does anyone have any ideas? Thanks in advance
  2 件のコメント
Stephen23
Stephen23 2017 年 5 月 21 日
@Amy Phan: you need to learn about the differences between array and matrix operations:
Niladri Halder
Niladri Halder 2022 年 8 月 9 日
nn2_p = nn2{nImage}.*mask_s;
Matrix dimensions must agree.
Please Help. Thank you.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2017 年 5 月 21 日
C = A.*B is element-by-element multiplication, for which unless one of A or B is a scalar, the result C(J,K) = A(J,K).*B(J,K) . For that to work, the matrices must be the same size.
Perhaps you want D_tranpose * D which would be algebraic matrix multiplication, and would give you a 6 x 6 result for those matrices.
  2 件のコメント
Amy Phan
Amy Phan 2017 年 5 月 22 日
Thank you so much for your reply. When I try and compute D_tranpose * D I receive another error saying:
Error using *
MTIMES is not fully supported for integer classes. At least one input must be scalar.
To compute elementwise TIMES, use TIMES (.*) instead.
Walter Roberson
Walter Roberson 2017 年 5 月 22 日
double(D_tranpose) * double(D)
When you do algebraic matrix multiplication involving uint8 the result is quite likely to exceed the capacity of uint8, so you would not want to use * directly between uint8 even if it were permitted.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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