What are some tips for writing efficient C/C++ code for S-Functions?
Show older comments
Can anyone give advices on what I should consider, if I want to write an efficient code in C/C++ for S-Functions?
For example, I am wondering if it is better to read values from Look-Up tables in Simulink, instead of calculating it in the C/C++ code and especially using (standard C) trigonometric functions?
Should I generally avoid standard C math-functions (e.g. a*a instead of pow(a, 2.0))?
Any other points that might be crucial to optimize C/C++ codes?
I think it would be useful to know of such points, if there are any.
Looking forward to any hints.
Accepted Answer
More Answers (2)
Jan
on 27 May 2011
1 vote
It depends on the compiler, the size of the data, the number of calls, the representation of the data (DOUBLEs, Integers, processing of contiguous memory blocks which fit in the processor cache), etc.
A C/C++ forum is a better location for this question.
MIchael
on 2 Jun 2011
0 votes
Categories
Find more on Simulink Coder in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!