フィルターのクリア

traverse the list of array elements

1 回表示 (過去 30 日間)
pammy
pammy 2013 年 3 月 13 日
i've code the following for traversing
function traverse
clc;
a=[ 1 2 2 3 3 4 4 4 4]
for i=1:length(a)
if(a(i)==a(i+1))
fprintf('\nmatch\n %d and %d',a(i),a(i+1));
else
fprintf('\nnot a match\n');
end
end
but the following error occurs
Attempted to access a(10); index out of bounds because numel(a)=9.
tell me the way to sort it out...

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 13 日
Use
for i=1:length(a)-1
  1 件のコメント
pammy
pammy 2013 年 3 月 13 日
thank u

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by