Map all the indices of an Array Indices into a Vector giving Index vs Row and Column - MATLAB Cody - MATLAB Central

Problem 771. Map all the indices of an Array Indices into a Vector giving Index vs Row and Column

Difficulty:Rate

Create an array of the row and column values for the indices of an array.

This is typically performed using [r c]=ind2sub(size(matrix), index).

The ind2sub output can be vectorized.

Create an index row/col array(irc) where index is the row of the irc array, column 1 is the array row and column 2 is the array column.

m=[0 0; 0 1] has four indices thus producing a four row and two column irc array.

 irc=
  [1 1
   2 1
   1 2
   2 2]

Index 4's row is irc(4,1)=2 and its col is irc(4,2)=2. The values of m are irrelevant.

Puzzle, and initial tightest solution, inspired by code implemented by Alfonso Nieto-Castanon.

Solution Stats

60.76% Correct | 39.24% Incorrect
Last Solution submitted on May 05, 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...
3
5
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 Solvers43

Suggested Problems

More from this Author308

Problem Tags

Community Treasure Hunt

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

Start Hunting!
Go to top of page