Error in port widths or dimensions.

3 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by