How can I evaluate an Simulink.data.Expression in a MATLAB script

Hi all,
In my data dictionary, I have a Simulink.Parameter whose value is set as an expression:
Parameter with properties:
Value: slexpr("single(420*pi/180)")
CoderInfo: [1×1 Simulink.CoderInfo]
Description: '...'
DataType: 'single'
Min: 0
Max: 20
Unit: 'rad'
Complexity: 'real'
Dimensions: [1 1]
Now I would like to get the numeric value of the parameter within a script. So how can I evaluate the expression
slexpr("single(420*pi/180)")
to get
ans =
single
7.3304
Any hint would be greatly appreciated. Thank you very much.

1 comentario

Assuming you have a variable set equal to the expression
parmVal = slexpr("single(420*pi/180")
it will be of class type 'Simulink.data.Expression'
The value can be determined by the following
parmVal=eval(parmVal.ExpressionString)

Iniciar sesión para comentar.

Categorías

Más información sobre Simulink Functions en Centro de ayuda y File Exchange.

Productos

Versión

R2022a

Etiquetas

Preguntada:

el 15 de Sept. de 2022

Comentada:

el 3 de Oct. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by