Simulink matrix multiplication error when passing matrix to model

3 views (last 30 days)
Hi,
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 the 6DOF fixed mass model.
The model itself looks like this:
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 don't know why this is happening as the dimensions are correct in my opinion. Is there a mistake in the way I pass the vectors and the matrix to the model?
Help is greatly appreciated.
Thanks

Answers (1)

Harald
Harald on 7 Jun 2024
Hi,
if DCM is 3x3, I'd expect the signal dimensions to indicate that. However, it shows 9, so I'd think that this is really a vector with 9 elements.
If that is the case, you can use a Reshape block to convert it to a 3x3 matrix. Depending on the ordering of elements in the vector, you may need to use a Transpose block on top of it.
Best wishes,
Harald

Categories

Find more on Simulink in Help Center and File Exchange

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!