MATLAB Function takes [4x1] signal as parameter, but in debug shows as [3x1]. Workaround/fix?
11 views (last 30 days)
Show older comments
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 Comment
Yash
on 1 Oct 2024
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.
Answers (1)
Arnav
on 7 Nov 2024 at 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:
0 Comments
See Also
Categories
Find more on Configure and View Diagnostics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!