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

Kaustubha Govind
Kaustubha Govind 2012년 9월 7일
편집: Kaustubha Govind 2012년 9월 7일
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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Simulink Functions에 대해 자세히 알아보기

질문:

2012년 9월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by