If statement using the value in the row before

I have a matrix and am trying to assign a new value to an entry in the matrix if the difference between the entry and the entry in the row before is greater than 180. I tried to just create a new matrix(B) that was the difference between the original matrix entries (A) and the entries before but got an error.
B= A(i,:)- A(i-1,:)
Error:
Subscript indices must either be real positive integers or logicals.

 採用された回答

James Tursa
James Tursa 2016 年 6 月 22 日

0 投票

You probably started the loop with i=1. When i=1, the i-1 index evaluates to 0, hence the error. Start your loop at i=2 instead.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2016 年 6 月 22 日

回答済み:

2016 年 6 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by