Simulink matrix multiplication error when passing matrix to model

2 次查看(过去 30 天)
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

回答(1 个)

Harald
Harald 2024-6-7
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

类别

Help CenterFile Exchange 中查找有关 General Applications 的更多信息

产品


版本

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by