error: Array indices must be positive integers or logic

1 回表示 (過去 30 日間)
Kayla Garcia
Kayla Garcia 2024 年 2 月 2 日
コメント済み: Walter Roberson 2024 年 2 月 2 日
please help

回答 (2 件)

VBBV
VBBV 2024 年 2 月 2 日
y(i) = y(i) + 1;
instead of
y(II) = y(II) + 1;
  2 件のコメント
VBBV
VBBV 2024 年 2 月 2 日
編集済み: VBBV 2024 年 2 月 2 日
The value of II may be a floatpoint number. MATLAB uses integer and 1 based indexing for accessing array elements
Kayla Garcia
Kayla Garcia 2024 年 2 月 2 日
thank you for the response. i have changed it and it is still giving me the same error message.

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


Walter Roberson
Walter Roberson 2024 年 2 月 2 日
Due to floating point round-off, the result A+(B*x(i)) might not be exactly an integer. You should round() it.
  2 件のコメント
Kayla Garcia
Kayla Garcia 2024 年 2 月 2 日
when i try round() i recieve a different message
Walter Roberson
Walter Roberson 2024 年 2 月 2 日
You have not posted enough context to really give you an answer.
But I suspect that you should have made x one element shorter. Something along the line of
x = linspace(xmin, xmax, number_of_steps+1);
x = x(1:end-1);

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

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by