Borrar filtros
Borrar filtros

Handling Struct and String Arrays in Simulink.

14 visualizaciones (últimos 30 días)
Ajpaezm
Ajpaezm el 20 de Dic. de 2018
Comentada: Walter Roberson el 23 de Jul. de 2024
Hey guys,
I have a function that has 3 types of outputs:
1) numeric array.
2) string array.
3) struct array.
Is there any possible way in which I can call this function from Simulink and use data from these 3 outputs? Do you have any examples of it? I'd like to know.
Thanks for your time!
Aquiles

Respuesta aceptada

Walter Roberson
Walter Roberson el 20 de Dic. de 2018
There is no way to create a Simulink signal that is a character vector or a string array or a struct array (except for a timeseries.)
Therefore to use that function inside Simulink, you would need to create a MATLAB Function Block that brought in the inputs from non-signal sources as necessary, and then called your function, and disposed of the results in non-signal ways.
The only alternative to this is that you could encode the string array or struct array as numeric signals and pass those around, and then decode them inside a MATLAB Function Block and then call your function and encode the results as numeric signals. For example you could use the fast serialization contribution from the File Exchange. Remember, though, that if you try to do this in continuous time instead of discrete time, that your signals are likely to be interpolated...
  2 comentarios
Robert
Robert el 23 de Jul. de 2024
why
Walter Roberson
Walter Roberson el 23 de Jul. de 2024
In the time since the previous post, String signals were added; https://www.mathworks.com/help/simulink/ug/simulink-strings.html
struct signals are handled by creating Bus Objects; https://www.mathworks.com/help/simulink/slref/simulink.bus.html . These are not compatible with regular struct objects.
why
Because the not very tall and not excessively bald programmer asked the very bald system manager.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Productos


Versión

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by