Why is my linear search algorithm not producing the output?

% begins by comparing x and a1
i := 1
while(i =< n and x /= a1)
i := i + 1
if i =< n
location := i
else
location := 0

 採用された回答

David Young
David Young 2011 年 11 月 27 日

0 投票

In MATLAB, assignment is
=
not
:=
as in, for example, Pascal.
Also, "not equals" is ~=, and structures such as while loops and if..else.. conditionals must be terminated with "end".
You should probably look at the "getting started" documentation, which is very good.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCall C++ from MATLAB についてさらに検索

製品

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by