Problem 2092. Find offset of an element of a multi dimensional matrix

For a given multi dimensional matrix and given element, find its offset from the 1st element.

Return 0, if element is not found in the matrix.

If the element is repeated in the matrix, then return the offset of its first occurrence in the matrix.

E.g. M(:,:,1) = [1 2 3; 4 5 6] M(:,:,2) = [10 20 30; 40 50 60]

Element is 50, then its offset = 10

Solution Stats

33.87% Correct | 66.13% Incorrect
Last solution submitted on Oct 21, 2016

Problem Comments

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