Problem 45973. How to locate the position of an element in a vector without using the find function

(copy of prob 105 with test for find function)

Write a function

posX = locatePos (x,y)

which returns the location of y within the vector x. You cannot use the find function.

Examples:

 locatePos([1 3 5 4 2], 2)
 posX is 5
 locatePos([1 5 8 6 7 6 0], 8)
 posX is 3

Solution Stats

64.41% Correct | 35.59% Incorrect
Last Solution submitted on Aug 04, 2023

Solution Comments

Show comments

Problem Recent Solvers38

Suggested Problems

More from this Author52

Problem Tags

Community Treasure Hunt

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

Start Hunting!