1x4 times 4x4 matrix in Matlab
Show older comments
Hi!
I have a 4x4 matrix (say P) and I need to multiply it with a 1x4 (say A) matrix. I saw the answers that I needed to do P*A' to get the right answer. But when I do that it is not the right solution, so did I maybe fill in wrong numbers in the matrix is that my mistake or is there another way to solve this multiplication?
3 Comments
KALYAN ACHARJYA
on 11 Dec 2020
You cant do the matix multiplication between P and A, where P is 4x4 and A is 1x4 as per basic matrix multiplication rules (Maths).
For matrix multiplication, the number of columns in the first matrix must be equal to the number of rows in the second matrix. The result matrix has the number of rows of the first and the number of columns of the second matrix.
"I have a 4x4 matrix (say P) and I need to multiply it with a 1x4 (say A) matrix."
According to the rules of matrix multiplication
the two adjacent dimensions must be the same. This means it is not possible to multiply a 4x4 matrix with a 1x4 matrix, but it is possible to multiply 4x4 by 4x1 to get a 4x1 matrix or 1x4 by 4x4 to get a 1x4 matrix. Which of these, if any, are correct for your situation depends on you knowing what operation you need to perform. It is also possible the matrix multiplication is entirely the wrong operation (perhaps you should be doing element-wise array multiplication?).
"But when I do that it is not the right solution, so did I maybe fill in wrong numbers in the matrix is that my mistake or is there another way to solve this multiplication?"
It is not clear what you mean by "solve this multiplication": from what you have told us so far we have no idea what exact values you tried, what exactly you expect the output to be, and how you checked the output, or even if this operation is suitable at all. Perhaps you are getting some floating point issues... we don't know, because you didn't show what you are doing nor what you expect.
Matrix multiplication does not need to be "solved", it already works according to the standard accepted definition.
Fleur van Delft
on 11 Dec 2020
Answers (1)
Daniel Pollard
on 11 Dec 2020
0 votes
Use the rules for matrix multiplication to help you. What solved one persons problem won't always solve yours.
A 4x4 multiplied by a 4x1 should work. A 4x4 multiplied by a 1x4 won't. In your case, P*A will return an error, but P*A' shouldn't.
If you copy and paste your code and any error messages, it makes it much easier to provide a comprehensive answer.
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!