I understand that you simplified the model by removing extra Simulink Demux blocks and seek a way to solve port width/dimension error.
There could be an issue in two places which could be the reason behind the error. My observations are based on assumptions about the input and output dimensions of the Simulink State-Space blocks. This is because the specific matrices, A, B, C, and D, that define these dimensions are not available.
- In the original model, the use of Demux block after the top State-Space block splits the output dimensions of the State-Space block into 2 outputs of dimension size of 1 each. This is then propagated to the Mux before the bottom State-Space block. The Mux then combines both signals to give an output dimension of size 2. However, in the simplified model, dimension of size 2 is being directly passed as second input in the Mux before the bottom State-Space block, while the first input is still of dimension size of 1.
- Moreover, the sum block on the right in the simplified model gets one input of dimension size 2 and other input of dimension size 1 which is incompatible.
To debug further, I suggest enabling “Signal Dimension” under Information Overlays. To do so, in the Simulink Editor, on the Debug tab, click Information Overlays > Signals > Signal Dimensions
To know more on Mux, Demux and State-Space blocks, kindly refer to the following MATLAB documentation:
I hope this is beneficial!