Failed to resolve data 'MinErr_re' in 'MATLAB Function' to a valid Simulink.Signal object.
Show older comments
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
2 Comments
Michael Hodgson
on 8 Oct 2021
Augusto, did you solve this? If so, how? I have an almost identical problem.
Vivek
on 17 Apr 2025
Augusto, did you solve this? If so, how? I have an almost identical problem.
Answers (1)
Pramil
on 13 May 2025
0 votes
Hey Augusto,
I faced a similar error in Simulink and this can be resolved through following steps:
- Add a "MATLAB Function" block into Simulink. Add the required function in it.
- Open "MODELING > Symbols Pane" and set the function inputs as parameters.
- Set the parameters as non-tunable by unchecking the "Tunable" option.
- 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.
Categories
Find more on Modeling in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!