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

3 visualizzazioni (ultimi 30 giorni)
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

Risposte (1)

Pramil
Pramil il 13 Mag 2025
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.

Categorie

Scopri di più su Modeling in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by