How to find the position of an element in a vector without using the find function - MATLAB Cody - MATLAB Central

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

Difficulty:Rate

Write a function posX=findPosition(x,y) where x is a vector and y is the number that you are searching for.

Examples:

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

Solution Stats

60.86% Correct | 39.14% Incorrect
Last Solution submitted on May 08, 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 Solvers2757

Suggested Problems

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