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
2 个评论
Michael Hodgson
2021-10-8
Augusto, did you solve this? If so, how? I have an almost identical problem.
回答(1 个)
Pramil
2025-5-13
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.
0 个评论
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!