evalin data dictionary design data unable to use parameters on rhs of expression

4 vues (au cours des 30 derniers jours)
I'm trying to write a MATLAB script that can perform pre-processing computations on a data dictionary prior to Simulink running. I've been trying to write a script that is called from the 'evalin' interface with the Dictionary design data section as the first input and my script as the second:
evalin(section,'my_script');
Assume the dictionary already has parameters x and y with some arbitry values
if my_script.m has:
x=1;
y=2;
There's no problem. If I modify my_script.m to:
y=x+1;
There is an error when calling evalin:
"Could not evaluate 'my_script' in data dictionary
Caused by:
Error occurred."
After further testing, it doesn't seem like I can use an existing parameter anywhere on the rhs of an equation. Is this correct?

Réponse acceptée

Mohith Kulkarni
Mohith Kulkarni le 28 Août 2020
The "evalin" function for data dictionary section does not support the expressions where the value contains data entries as of now. But I have brought this issue to the concerned people and it might be considered in any future release.

Plus de réponses (1)

stozaki
stozaki le 28 Août 2020
Modifié(e) : stozaki le 28 Août 2020
The "evalin" function for data dictionary section does not support the expressions.
The workaround can be replaced by the following formula.
Simulink.data.evalinGlobal(modenName,expression)
For example, how about preparing a wrapper function like the following?
function [Object] = evalinCustomWrap (modelName,varStr)
modelVar = verLessThan('Simulink','8.5');
if ~modelVar
% If the target model is using a MATLAB release supported by .sldd
try
Object = Simulink.data.evalinGlobal(modelName,varStr);
catch
Object = [];
end
else
% If the target is using a MATLAB release that does not support sldd
% Only evalin can be used
try
Object = evalin('base',varStr);
catch
Object = [];
end
end
end
Regards,
stozaki
  1 commentaire
Adam Jaslikowski
Adam Jaslikowski le 28 Août 2020
I'm experiencing the same issue when attempting to use Simulink.data.evalinGlobal. This is very dissappointing. I just learned of data dictionaries and they seem like very useful tools; however, my use case requires a great deal of pre-processing on the data prior to use by the Simulink model and it seems like that is just not supported (other than doing a lot of calls to "getEntry" and "getValue"). Thank you for trying to help,
Adam

Connectez-vous pour commenter.

Catégories

En savoir plus sur Simulink Functions dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by