How can one make this extraction?

2 views (last 30 days)
alpedhuez
alpedhuez on 15 Jul 2022
Commented: Torsten on 15 Jul 2022
I have a 3-D array where the first column is month, the second column is city, and the third column is a vector of temperature of the city in that month. I have previosuly sorted the temperature in the descending order. Then I now want to create a 3-D array where the first column is month, the second column is city, and the third columnis the n-th highest temperature of the month of the city. Please advise how to proceed.

Accepted Answer

Steven Lord
Steven Lord on 15 Jul 2022
I have a 3-D array where the first column is month, the second column is city, and the third column is a vector of temperature of the city in that month.
So the array has size [N 3] for some value of N? That's not a 3-dimensional array. That's a matrix with three columns.
Then I now want to create a 3-D array where the first column is month, the second column is city, and the third columnis the n-th highest temperature of the month of the city.
I'm going to assume you mean that you want another matrix with three columns. As you've described it, you should use the groupsummary function. You can use the "Multiple Grouping Variables" or "Multiple Grouping Vectors for Vector Input" examples on that documentation page as a model.
  4 Comments
alpedhuez
alpedhuez on 15 Jul 2022
Thank you. Is there any simple way to extract the second highest, third highest,...?
Torsten
Torsten on 15 Jul 2022
k-th highest:
A = squeeze(A(:,:,k))

Sign in to comment.

More Answers (0)

Categories

Find more on Tables in Help Center and File Exchange

Tags

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!