Error with matrix multiplication?

4 Ansichten (letzte 30 Tage)
Shayma Al Ali
Shayma Al Ali am 14 Dez. 2020
Beantwortet: Jan am 14 Dez. 2020
I have two matrices I'd like to multiply. Matrix A has dimensions 107x817. Matrix B has dimensions 817x1. My understanding of matrix multiplication is that the inner dimensions have to agree. So if I multiply A*B than it should work? However, I keep getting back an error.

Antworten (2)

Matt J
Matt J am 14 Dez. 2020
Bearbeitet: Matt J am 14 Dez. 2020
Yep, it should work, as the following example shows. I would check to make sure the matrix dimensions are really what you think they are.
A=rand(107,817); B=rand(817,1);
C=A*B;
whos A B C
Name Size Bytes Class Attributes A 107x817 699352 double B 817x1 6536 double C 107x1 856 double

Jan
Jan am 14 Dez. 2020
This should work. Use the debugger to let Matlab stop when the error occurs - type this in the command window:
dbstop if error
Then run your code again. If Matlab stops, check if the sizes of the arrays are what you expect them to be.

Kategorien

Mehr zu Function Creation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by