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

Walter Roberson
Walter Roberson 2018년 2월 1일
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
Tayler Evans 2018년 2월 1일
Hi there, sorry about that, i have never posted to this before, I have attached my code to this now
Stephen23
Stephen23 2018년 2월 1일
편집: Stephen23 2018년 2월 1일
'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:

댓글을 달려면 로그인하십시오.

답변 (2개)

Star Strider
Star Strider 2018년 2월 1일

0 개 추천

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
Tayler Evans 2018년 2월 5일

0 개 추천

Thanks for the help everyone, I figured out the problem I was having based on all of your responses. Thank you thank you thank you! :D

카테고리

도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

질문:

2018년 2월 1일

답변:

2018년 2월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by