Passing array into Stateflow graphical function for modification?

I am trying to write a simple Stateflow graphical function that inputs an array, modifies its contents, and then outputs the array (as a void function would do in C). Stateflow doesn't seem to allow me to do this, as I can't define the array to be an output and input simultaneously. My workaround so far copies the input array, and then modifies the copied version for output. E.g,
arr_out1 = testfun(saclar_in1, saclar_int2, arr_in1[4])
which simply does:
{
arr_out1 = arr_in1;
arr_out1[0][0] = saclar_in1*2;
arr_out1[0][1] = saclar_in2*2;
}
When generating C gode, I can see that the graphical function of this kind into the C version I desire:
static void Chart_testfun(real_T saclar_in1, real_T saclar_in2, real_T arr_in1[4])
{
arr_in1[0] = saclar_in1 * 2.0;
arr_in1[2] = saclar_in2 * 2.0;
}
I believe, though, that the performance of my Stateflow model is decreased by the copying of large arrays that occurs in the graphical function similar to the one I described.

1 comentario

Kaustubha Govind
Kaustubha Govind el 7 de Sept. de 2012
Editada: Kaustubha Govind el 7 de Sept. de 2012
I think what you're suggesting is support for "in-place operations" in Stateflow? I'm not sure that this is supported in Stateflow - I would recommending checking with MathWorks Technical Support and submitting an enhancement request if they confirm that.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

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

Productos

Preguntada:

el 6 de Sept. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by