Error in port widths or dimensions.

1 回表示 (過去 30 日間)
MAGDALINI EFTHYMIADOU
MAGDALINI EFTHYMIADOU 2022 年 6 月 12 日
回答済み: Brahmadev 2023 年 9 月 8 日
I run my code in Matlab and my circuit in Simulink shows this error:
How can I solve that?
** I would like to add that whenever I run my code in Matlab and then I run Simulink my circuit works right. But whenever I make a change in Simulink (for example change a manual switch) and I don't run my code in Matlab after that change, the error occurs.

回答 (1 件)

Brahmadev
Brahmadev 2023 年 9 月 8 日
Hi,
I understand that you are using the 'From' and 'GoTo' block to manipulate input data in Simulink. Here are some possible causes for the errors:
  1. When you run your MATLAB code before running the Simulink model, it sets up the necessary variables or configurations that the Simulink model relies on. However, if you make changes in Simulink without rerunning your MATLAB code, those dependencies might not be met, leading to errors. Better Approach: Use Simulink Callbacks for initializing data that is being used in the model.
  2. Blocks such as 'Gain' or 'Product' might be set to 'Matrix Multiplication' instead of 'Element-wise Multiplication' causing a mismatch in size.
You can refer to the following MathWorks documentation for Model Callback functions:
Hope it helps!

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by