MATLAB Function takes [4x1] signal as parameter, but in debug shows as [3x1]. Workaround/fix?

11 次查看(过去 30 天)
The context here is I am using a MATLAB function which takes a parameter y (x_est) which is shown to be a [4x1] signal above. When 'make model' is clicked it gives the error below:
On inspection of the diagnostic report:
This shows that the [4x1] signal (which is initialised as [4x1] by an integrator block) is being interpreted as [3x1]. I am clueless as to why.
  1 个评论
Yash
Yash 2024-10-1
Hi Ben,
This is an unexpected behaviour. Does the issue persist if you remove the logic on the Right Hand Side of the MATLAB function block (including the feedback loop)? There is a possibility that the feedback loop is chaging the input size after a few iterations.
If the issue still persist, share the model here so that we can have a look at the issue.

请先登录,再进行评论。

回答(1 个)

Arnav
Arnav 2024-11-7,5:15
From the image of the model provided, the Mux block combines 2 signals of width 2 and this is provided as input to the Gain block. The gain is using depicted through matrix multiplication (indicated as K*u on the mask where K is the gain).
It is not possible for the output to be a signal of width 2 for any gain matrix. The output of the gain block is provided as feedback to the system that computes speed_observation. Due to this, Simulink is unable to find the correct dimensions for the signals because signal dimensions are defined by a cyclic relationship.
You can fix this by directly using the speed_observation signal as input to the Gain block.
You can refer to the documentation of Gain block and Mux block to understand how dimensions of input and output signals are computed:

类别

Help CenterFile Exchange 中查找有关 Configure and View Diagnostics 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by