Error in port widths or dimensions.

1 view (last 30 days)
MAGDALINI EFTHYMIADOU
MAGDALINI EFTHYMIADOU on 12 Jun 2022
Answered: Brahmadev on 8 Sep 2023
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.

Answers (1)

Brahmadev
Brahmadev on 8 Sep 2023
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!

Categories

Find more on Simulink Functions in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!