Error: Invalid operands to binary /

How can I solve this problem?
Error: Invalid operands to binary / (have 'real_T {aka const double}' and 'const real_T * {aka const double *}')
dx[3] = xC[11]*xC[4] - xC[10]*xC[5] + u[0]/Mass;
^
The '/' is where the error happens.

回答 (2 件)

Jiaming Wu
Jiaming Wu 2020 年 4 月 4 日
編集済み: Image Analyst 2020 年 4 月 4 日

1 投票

Change this
dx[3] = xC[11]*xC[4] - xC[10]*xC[5] + u[0]/Mass;
to
dx[3] = xC[11]*xC[4] - xC[10]*xC[5] + u[0]/Mass[0];
Image Analyst
Image Analyst 2018 年 7 月 6 日

0 投票

MATLAB uses round parentheses, not square brackets, to indicate array elements. Arrays also start at 1, not 0.
dx(3) = xC(12) * xC(5) - xC(11) * xC(6) + u(1)/Mass

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

質問済み:

2018 年 7 月 6 日

編集済み:

2020 年 4 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by