MATLAB: Matrix dimensions must agree.

MATLAB

hi, I am getting this error in my code. can anybody help me with this. Thank you in advance.

Best Answer

On that line instead of the right-matrix division operator (which does matrix division):
/
you need to use the right array division operator (which works element-wise):
./
And read this to know the difference:
because you will fix that line and get exactly the same error on the following lines. When you understand the difference between matrix and array operations then you can solve this yourself.
Related Question