フィルターのクリア

Error:Index exceeds matrix dimensions.

1 回表示 (過去 30 日間)
KalMandy
KalMandy 2016 年 11 月 13 日
回答済み: Jan 2016 年 11 月 14 日
I have two arrays;
onpointX1 =
NaN NaN NaN NaN NaN NaN NaN
onpointX2 =
NaN NaN NaN NaN NaN 0.5830 0.5161
Note that the elements which are not NaN always equal to crossX(k,1) or crossX(k,2).
I run a for loop,
for k=1:length(onpointX1)
onpointX1(8)=onpointX1(1);
onpointX2(8)=onpointX2(1);
I get an error when the for loop is at k=7
Index exceeds matrix dimensions.
at;
else if isnan(onpointX1(k)) && onpointX2(k)==crossX(k,2)&& onpointX1(k+1)==crossX(k+1,1) && isnan(onpointX2(k+1))
I can not understand why this happens because I have defined onpointX1(8) and onpointX2(8) right after initiationg the for loop.
Can anybody help me with this? Thanks.
  1 件のコメント
Alexandra Harkai
Alexandra Harkai 2016 年 11 月 14 日
What is the actual code you're running?
What is crossX?

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

回答 (1 件)

Jan
Jan 2016 年 11 月 14 日
Use the debugger for further investigations:
dbstop if error
Run the code again until it stops at the error and check the dimensions of the used variables:
size(onpointX1)
size(onpointX2)
size(crossX)
Then you will find out, which variable causes the error.
Debugging locally is more efficient than asking the forum, which cannot guess the details.

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by