Sum matrix from n=1 to n
Show older comments
Hello,
I have E matrix which is 24*3*4. I want to sum the maximum values that corresponding to a specify (n). lets say i want to sum different number of maximum values of each row. for example, the first row of E(1,1:3,1:4)=
ans(:,:,1) =
31 32 33
ans(:,:,2) =
21 22 23
ans(:,:,3) =
71 72 73
ans(:,:,4) =
51 52 53
now i want to sum the the two maximum values of 1 which are 33 , 32 and the maximum value of 2 which is 23 and two maximum values of 3 which are 73,72 and the three maximum values of 4 which are 51,52,53. So, the result should be a matrix which diminsion is (24*1*4) and look like
ans(:,:,1) =
65
ans(:,:,2) =
23
ans(:,:,3) =
145
ans(:,:,4) =
156
Any thought of how i can do that . Many thanks :)
2 Comments
Image Analyst
on 4 Oct 2020
I'd guess sort() and sum() would be involved. But make it easy for people to help you, not hard -- attach "E" in a .mat file
save('answers.mat', 'E');
Then attach answers.mat with the paper clip icon.
Mohammed Alruwaili
on 4 Oct 2020
Accepted Answer
More Answers (0)
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!