Find a common vertex - MATLAB Cody - MATLAB Central

Problem 45217. Find a common vertex

Difficulty:Rate

First input is T, a triplet list of indices. Second input is i, a single index (positive integer). The goal of this function is to find and return the indices of the rows in the list which contain this particular index. Output format is indifferently a column or a row vector.

For example if inputs are

T = [1 2 3;...
     1 3 4;...
     1 4 2;...
     2 3 4]

and

i = 2

the output is the vector

row_idx = [1 3 4]

since 2 is contained in rows number 1, 3, and 4 of T. If the index is not in the list, the function must of course return the empty set. Each index is at most contained once per row / triplet.

Solution Stats

72.22% Correct | 27.78% Incorrect
Last Solution submitted on May 06, 2025

Problem Comments

Solution Comments

Show comments
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
3

Problem Recent Solvers35

Suggested Problems

More from this Author9

Community Treasure Hunt

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

Start Hunting!
Go to top of page