Why do i keep get the message "Index expression out of bounds" ?

2 ビュー (過去 30 日間)
Hung Ly
Hung Ly 2022 年 3 月 29 日
回答済み: Abhaya 2024 年 9 月 19 日
I'm simulating a sliding-mode controller with Simulink. Some function in my subsystems keep getting the message "Index expression out of bounds". I have 4 signal go into the mux block, so it supposes to be ranged from 1 to 4 but in the diagnostic viewer said the range is 1-1.

回答 (1 件)

Abhaya
Abhaya 2024 年 9 月 19 日
Hi Hung,
I encountered a similar issue when using a Simulink Mux block alongside a MATLAB Function block. The error occurs because the Simulink Mux block outputs a virtual vector, which the ‘MATLAB Function’ block processes as individual double values. To resolve this error, you can set a fixed size for the input to the MATLAB Function block.
Follow these steps to address the issue:
  1. Open the MATLAB Function block within your model.
  2. In the Function tab, select the 'Edit Data' icon.
3. In the Symbol pane at the bottom left corner, click on the 'u' variable.
4. In the Property Inspector, set a fixed size for the variable 'u'.
To explore more about Simulink ‘Mux’ block, please refer to the following MATLAB documentation.
Hope this resolves the issue.

カテゴリ

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

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by