Failed to resolve data 'MinErr_re' in 'MATLAB Function' to a valid Simulink.Signal object.

3 次查看(过去 30 天)
I am trying to use embedded Matlab inside simulink. This small model is running in float point.
The model (function) has two inputs: One real and the second one imaginary. What it does is simple calculation of the the Euclidean distance from the input symbol with respect to a known pre-defined set. In the case for simplification is QPSK.
function [MinErr_re, MinErr_im] = fcn(Symb_re, Symb_im)
d_re= [1 1 -1 -1]
d_im= [1 -1 1 -1]
EstErr_re=d_re-Symb_re
EstErr_im=d_im-Symb_im
AbsErr=EstErr_re.^2+EstErr_im.^2
zzz=min(AbsErr)
index=find((AbsErr-zzz)==0)
MinErr_re=EstErr_re(index )
MinErr_im=EstErr_im(index)
When I run this function in Matlab (.m) it works well but when I embed it into simulink and try to run simulink it shows the following error message: Failed to resolve data 'MinErr_re' in 'MATLAB Function' to a valid Simulink.Signal object.
I already forced Simulink to resolve the data type but it did not work. It will show for MinErr_im as well as soon as I comment the first error. Therefore, both outputs have the same problem.
Thanks and best regards,
Augusto

回答(1 个)

Pramil
Pramil 2025-5-13
Hey Augusto,
I faced a similar error in Simulink and this can be resolved through following steps:
  1. Add a "MATLAB Function" block into Simulink. Add the required function in it.
  2. Open "MODELING > Symbols Pane" and set the function inputs as parameters.
  3. Set the parameters as non-tunable by unchecking the "Tunable" option.
  4. Define the inputs either in model or base workspace.
This would resolve the issue. I have attached a working model for your reference.
Hope it helps.

类别

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

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by