Why am I getting an : Error using sym/subsasgn (line 1058) Invalid indexing or function definition. Indexing must follow MATLAB indexing. Function arguments must be symbolic

2 ビュー (過去 30 日間)
Hazel Can
Hazel Can 2022 年 4 月 5 日
回答済み: R 2024 年 1 月 25 日
Hello, I am writing a code to solve my Forward Euler Method question. I added my question here.
I am encountering an error while writing the code; error :
Error using sym/subsasgn (line 1058)
Invalid indexing or function definition. Indexing must follow MATLAB indexing. Function arguments must be symbolic variables, and function body must be sym expression.
I would be very grateful if you could help me how to fix this error.
  1 件のコメント
Torsten
Torsten 2022 年 4 月 5 日
You did not include the part of your code where you use symbolic variables now conflicting with a numerical computation.

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

回答 (1 件)

R
R 2024 年 1 月 25 日
Hello Hazel,
This error occurs when using a symbolic variable as both a summation index for the "symsum" function and an index into an array. The "symsum" function requires the summation index to be a symbolic variable type, but as far as I understand, MATLAB indexing rules do not currently allow indexing into an array with a symbolic variable.
To work around this, compute the series with a for-loop instead.
I hope this addresses the error you are facing.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by