Subtracting matrices by column and performing a summation.
Hello all. I am new to MatLab but I am hoping to use it for a component of my research. I am going to create matrices and hopfully perform calculations with them in MatLab.
I am going to have matrices that are 3 x X number of points. Usually they will be around 3 x 1500. I am trying to create a code that will subtract the second element value from the first element value for positions i j and k. It would perform this calculation all the way through 1500 lines and then perform a summation of each column at the end. Here is an example.
[0 0 10]
[2 5 8]
[-5 10 6]
Those would be the first 3 of the 1500 lines. The code would subtract 0 from 2 (take the absolute value of that), then add that to -5 minus 2 (take the absolute value of that) and continue that down. It would also subtract 0 from 5 (take the absolute value of that), then add that to 10 minus 5 (take the absolute value of that) and continue that down. Then it would subtract 10 from 8 (take the absolute value of that), then add that to 6 minus 8 (take the absolute value of that) and continue that down.
At then end I would have three values: An absolute value summation of the change in the first column of elements, an absolute value summation of the change in the second column of elements, and an absolute value summation of the change in the third column of elements.
Any help is much appreciated! I am learning MATLAB and will try this out on my own in the meantime. Thank you!Hello all. I am new to MatLab but I am hoping to use it for a component of my research. I am going to create matrices and hopfully perform calculations with them in MatLab.
I am going to have matrices that are 3 x X number of points. Usually they will be around 3 x 1500. I am trying to create a code that will subtract the second element value from the first element value for positions i j and k. It would perform this calculation all the way through 1500 lines and then perform a summation of each column at the end. Here is an example.
[0 0 10]
[2 5 8]
[-5 10 6]
Those would be the first 3 of the 1500 lines. The code would subtract 0 from 2 (take the absolute value of that), then add that to -5 minus 2 (take the absolute value of that) and continue that down. It would also subtract 0 from 5 (take the absolute value of that), then add that to 10 minus 5 (take the absolute value of that) and continue that down. Then it would subtract 10 from 8 (take the absolute value of that), then add that to 6 minus 8 (take the absolute value of that) and continue that down.
At then end I would have three values: An absolute value summation of the change in the first column of elements, an absolute value summation of the change in the second column of elements, and an absolute value summation of the change in the third column of elements.
Any help is much appreciated! I am learning MATLAB and will try this out on my own in the meantime. Thank you! Hello all. I am new to MatLab but I am hoping to use it for a component of my research. I am going to create matrices and hopfully perform calculations with them in MatLab.
I am going to have matrices that are 3 x X number of points. Usually they will be around 3 x 1500. I am trying to create a code that will subtract the second element value from the first element value for positions i j and k. It would perform this calculation all the way through 1500 lines and then perform a summation of each column at the end. Here is an example.
[0 0 10]
[2 5 8]
[-5 10 6]
Those would be the first 3 of the 1500 lines. The code would subtract 0 from 2 (take the absolute value of that), then add that to -5 minus 2 (take the absolute value of that) and continue that down. It would also subtract 0 from 5 (take the absolute value of that), then add that to 10 minus 5 (take the absolute value of that) and continue that down. Then it would subtract 10 from 8 (take the absolute value of that), then add that to 6 minus 8 (take the absolute value of that) and continue that down.
At then end I would have three values: An absolute value summation of the change in the first column of elements, an absolute value summation of the change in the second column of elements, and an absolute value summation of the change in the third column of elements.
Any help is much appreciated! I am learning MATLAB and will try this out on my own in the meantime. Thank you! matrices, subtracting, absolute value MATLAB Answers — New Questions