std exception 'class std::out_of_range' : 'invalid unordered_map<K,T> key' was caught

22 ビュー (過去 30 日間)
Hamza
Hamza 2025 年 3 月 24 日
回答済み: Spruha 2025 年 3 月 26 日
Hello all,
I use simulink 2020b and when i run my model and it reach the initializing step I get the error " std exception 'class std::out_of_range' : 'invalid unordered_map<K,T> key' was caught ", it doesn't even show where the error is from or which block,
any Idea how to approach this error ?
  2 件のコメント
Amish
Amish 2025 年 3 月 25 日
Can you share the model or exact error message? Some screenshots might help understand the issue better.
Hamza
Hamza 2025 年 3 月 25 日
編集済み: Hamza 2025 年 3 月 25 日
I can't share the model but this is the Error I get after compiling and the start of initializing

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

回答 (1 件)

Spruha
Spruha 2025 年 3 月 26 日
Hi Hamza,
The error "class std::out_of_range": "invalid unordered_map<K,T>key" means that the model is trying to access a key in an unordered_map that does not exist. This issue often occurs in complex models that contain nested subsystems or several data dictionaries. Without the model, I can only suggest potential causes.
Possible causes can be:
  • When there is complex interaction between nested subsystems, it may lead to timing issues where one subsystem is trying to access data before it's been generated by another.
  • A block might be trying to access data in the unordered_map before the data is inserted, this data dependency can lead to an invalid key error.
  • When there is custom S-Functions or Embedded MATLAB Functions with internal unordered_map implementation, there could be logic errors or incorrect interactions with other data structures
You can try these to fix the error:
  • Verify your model's subsystem relationships, initialization, and data flow.
  • To identify the problem, use displays, scopes, and limited simulation stepping.
  • Check for logical problems in the custom blocks.
Hope this helps!

カテゴリ

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