Summation of two matrices

10 views (last 30 days)
Dominik Jerinic
Dominik Jerinic on 13 Nov 2021
Commented: Dominik Jerinic on 13 Nov 2021
Hi guys,
I really need your help with the summation of matrices in Matlab.
I have two matrices (180,360), which counts a total of 129 600 values, with different numbers. I would like to sum all the elements within this two matrices as follows:
  • value from the 1st row and 1st coloumn of the 1st matrix sum with the value from the 1st row and 1st coloumn of the 2nd matrix,
  • value from the 1st row and 2nd coloumn of the 1st matrix sum with the value of from the 1st row and 2nd coloum of the 2nd matrix,
  • and so on until the end.
I tried to do next:
Z = A + B and I get only one value in the last row and last coloumn. All the others values are zero (0) even the values in the both matrices are NOT zero (0). I also tried to use funtion SUM like Z = sum (A + B) but I got the result equel to 2 x Z in the last row and last coloumn.
Is there any other (easy) trick to sum this matrices?
Thank you in advance.
  4 Comments
Dominik Jerinic
Dominik Jerinic on 13 Nov 2021
OK, I find out what was wrong in my calculation.
I had (j,i) in the brackets after Izb_hv_bl and Izb_hv_p. Now I deleted this brackets and everything seems to sum right.
I will check that one more time but I thing it will work fine.
Thank you for your help and your time.
Best regards mate.

Sign in to comment.

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!