Index one element in each vector of an array along a given dimension - MATLAB Cody - MATLAB Central

Problem 1896. Index one element in each vector of an array along a given dimension

Difficulty:Rate

Functions like min and max can return in their second output argument the index of the element in each vector along a particular dimension which meets the particular criterion being requested. E.g.

   A = rand(3);
   [B, I] = min(A, [], 2);

Write a function which, given an array A, and an index array I (like the one created above), can reconstruct the first output of functions like min and max. E.g.

   C = dimsel(A, I);

such that C is equal to B.

Solution Stats

16.88% Correct | 83.12% Incorrect
Last Solution submitted on Apr 03, 2025

Problem Comments

Solution Comments

Show comments
PIVlab surpasses 100K all-time File Exchange downloads
During the past twelve months, PIVlab, a MATLAB Community Toolbox for particle...
4
8
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
4

Problem Recent Solvers49

Suggested Problems

Problem Tags

Community Treasure Hunt

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

Start Hunting!