Matrix Multiplication Having Problems
Ältere Kommentare anzeigen
Hello, I am having difficulty multiplying matrices in my code. For some reason, even though the matrices are the same size, I am still getting: "Error using * Inner matrix dimensions must agree."
Also, when plotting R using MH.*ML instead of just * , it is supposed to be a sinusoidal function; however, when I plot it, it is just a straight line. The range of plotting should be from lambda = 400:700.
What is going wrong?
The code is also attached

3 Kommentare
Walter Roberson
am 1 Feb. 2018
Sorry, my version of MATLAB does not appear to have the feature of dragging and dropping an image in order to test the code pictured in the image, so I seem to be short of information about which line the error message is occurring on.
Tayler Evans
am 1 Feb. 2018
'For some reason, even though the matrices are the same size, I am still getting: "Error using * Inner matrix dimensions must agree."'
Two matrices being the same size has never been a prerequisite for matrix multiplication:
Antworten (2)
Star Strider
am 1 Feb. 2018
If you want to do matrix multiplication, you have to transpose the second matrix, ‘ML’ to get a (2x2) result for ‘M’.
M = sqrt(MH*ML');
If you want to do element-wise multiplication, replace * with .* giving a (2*8) result:
M = sqrt(MH.*ML);
Tayler Evans
am 5 Feb. 2018
0 Stimmen
Kategorien
Mehr zu Matrix Indexing finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!