Cody

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

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

39.33% Correct | 60.67% Incorrect
Last solution submitted on Aug 30, 2016

Problem Comments

Solution Comments

Tags

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!

Join the 15-year community celebration.

Play games and win prizes!

Learn more