Generating code for a single element array

We have a model that interfaces to a legacy variable that is defined as a single element array. The variable's definition comes from a legacy header file, thus we have created our input data object as a Simulink.Signal using the ImportFromFile storage class.
If I set the signal Dimensions to 2 and use a demux or Selector to select the 1st element I get the correct generated code, something like:
temp = mySingleElementArray[0];
However, if I give it a dimension of 1 (which is what it should be) then it is treated as a scalar; even if I put a demux or Selector on the signal. So the generated code is:
temp = mySingleElementArray;
Which loads the address of the array into temp.
How do I define the input signal object so the code treats this variable correctly?

 채택된 답변

TAB
TAB 2012년 5월 1일

0 개 추천

You can set the Storage class of signal ImportedExternPointer. In your legacy code, write the actual definition of this pointer and assign the address of your array element.
Anyhow! it is not clear why you are using a scalar as a single element array in your legacy code.

댓글 수: 1

Todd
Todd 2012년 5월 17일
yes this approach works, which is what we were using, it just requires some special processing on our part.
The legacy s/w is configurable so this variable may have more than one element depending on the configuration, for example a cam sensor reading. If you have an inline 4 cylinder engine there is only one cam, if you have a v8 there are 2 cams. This configuration is done at compile time.

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

추가 답변 (0개)

카테고리

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

태그

질문:

2012년 4월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by