How can I generate code for a Simulink model that uses exponents without enabling support for nonfinite numbers?

조회 수: 1 (최근 30일)
I have a Simulink model that requires the use of exponents for some of its calculations. I would like to generate code from the model, however for a variety of reasons I can't enable support for non-finite numbers. I've tried saturating the inputs to avoid negative numbers to non integer exponents, etc., creating my own math expression using the Fcn block but despite all of this Simulink seems to think that any exponent requires NaN support. Is there a way around this?
  댓글 수: 3
NJ2Cali
NJ2Cali 2023년 6월 27일
Floating point.
I did some more digging into the model and it turns out that saturation helpeed, but there were other blocks in the code that required nonfinite number support.
I guess the follow up question is, is there a way to easily figure out which blocks are requiring nonfinite number support? As of now my approach is to generate code, look for NaN in the generated code, and work backwards from there. However, some functions (such as exponent) generate differently if NaN is supported even if they themselves don't require NaN support, so it's tricky to pin down the cause. I'm still working on it in my case.
NJ2Cali
NJ2Cali 2023년 6월 27일
I added the second half of my comment as an answer to my original question.

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

답변 (1개)

NJ2Cali
NJ2Cali 2023년 6월 27일
편집: NJ2Cali 2023년 6월 27일
I did some more digging into the model and it turns out that saturation helped, but there were other blocks in the code that required nonfinite number support.
I guess the follow up question is, is there a way to easily figure out which blocks are requiring nonfinite number support? As of now my approach is to generate code, look for NaN in the generated code, and work backwards from there. However, some functions (such as exponent) generate differently if NaN is supported even if they themselves don't require NaN support, so it's tricky to pin down the cause. I'm still working on it in my case.
  댓글 수: 1
Kiran K
Kiran K 2024년 1월 23일
Hi,
>>However, some functions (such as exponent) generate differently if NaN is supported even if they themselves don't require NaN support,
Did you solve this problem or found any workaround?. I also face similar problem.
Also, how did you manage by saturating the inputs.
When I changed below options there was no impact in generated code of exp functions
  • minimum and maximum values in Inport->Signal attributes
  • using saturation block

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

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by