Info
This question is closed. Reopen it to edit or answer.
How to make a matrix that 'matches' with another matrix.
1 view (last 30 days)
Show older comments
Hi,
I am trying to compute a matrix which 'matches' certain values in another matrix.
Here is where we start. The numbers in columns 1 and 2 which are also in the same row, need to be added together. For the first row, the number 1 needs to pull out the value 10 from MatrixB and add it with the number 2 which is 20. Thus giving us 30.
MatrixA
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/189248/image.png)
These are the values that need to be extracted. MatrixB
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/189250/image.png)
Now this is the plot twist and where I am stuck. The value 30 needs to be divided by 5 because there were values 1 and 2 in Matrix A. In MatrixC, the value next to 1 and 2 is 5.
Here is another example to ensure I get my question across. Numbers 2 and 3 (row 3, columns 1 and 2) will extract the values 20 and 30 which will make 50, this 50 needs to be divided by 7, which will give us 7.1428.
MatrixC
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/189251/image.png)
The final output, should look like this. A 4x1 matrix.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/189252/image.png)
Here is my attempt at coding it:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/189254/image.png)
0 Comments
Answers (0)
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!