Search code examples
matlabinputmodelmatrix-multiplicationsimulink

Simulink: Error in port widths or dimensions when passing matricies to model


I am trying to create a simulink model that does a few matrix multiplications but I cant seem to get the inputs right.

This is the setup of the model. Wind and gravity are 3x1 vectors and DCM is a 3x3 matrix coming from a 6DOF fixed mass object.

Use of Model

The model itself looks like this:

Model contents

Given the dimensions the expected multiplications should result in (3x3) * (3x1) = (3x1). However, when running the simulation i get several dimension mismatch errors.

Error using uavsim (line 7)
Error due to multiple causes.
Caused by:
    Error using uavsim (line 7)
    Error in port widths or dimensions. 'Output Port 1' of 'storm_uav/Constant2' is a [3x1] matrix.
    Error using uavsim (line 7)
    Error in port widths or dimensions. 'Input Port 1' of 'storm_uav/Model5' is a one dimensional vector with 1 elements.

I'm not sure what the problem is here as the dimensions should be correct in my opinion. It seems like I cannot pass the vectors to the given model as the model expects some other dimension even though it should be inherited?

Help is greatly appreciated.


Solution

  • You are using a model reference, which I am not really familiar with, but it is kind of a pre-compiled block. According to the Help Center, such a block has "a defined interface", which makes "the referenced model independent of its context in the model hierarchy".

    So the input dimensions are probably not inherited for this reason. You can verify this by directly copying & pasting the content of this block in a regular subsystem to check if it works as expected.

    EDIT:

    To define the signal attribute of the interface, in particular the dimension of it, you need to specify the dimension of the root-level Inport of the reference model (more information => Help Center).