script that finds a number using binary search?

I´m trying to do a script that orders an array of numbers, and then goes into a cycle that asks a number and returns if it´s there and it´s position. I´m new to the program but I´m currently using “sort” function to arrange the numbers and “while” for the cycle. I appreciate your help!

 採用された回答

John D'Errico
John D'Errico 2016 年 4 月 4 日
編集済み: John D'Errico 2016 年 4 月 4 日

0 投票

Why do something complicated? Learn to use MATLAB, as it is designed to be used.
find(V == n)

1 件のコメント

Santiago Tellechea
Santiago Tellechea 2016 年 4 月 4 日
I appreciate the truthful comment and I couldn't agree more. Still, I want to get the bases of the program correct and know the functions of both a cycle like while and the binary search. Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by