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 Comment

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.

Sign in to comment.

Answers (0)

Categories

Asked:

on 6 Sep 2012

Community Treasure Hunt

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

Start Hunting!