Using the C++ Math Library    

Control Structure

Both C++ and MATLAB support if-statements, for-loops, and while-loops. The primary difference between the C++ and MATLAB versions of these constructs is syntactical. For instance, in MATLAB the end keyword terminates a for-loop; in C++ braces surround the body of the loop.

There are two subtle functional differences, however, between the C++ and MATLAB for-loop constructs, both concerning the index for the loop. In C++ you can modify the for-loop index and the bounds for the index in the middle of the loop. In MATLAB the interpreter ignores any modifications to the loop index or its bounds.

The second subtle difference between the two for-loops is the final value of the index variable. When a MATLAB loop terminates, the index variable is equal to the loop's upper bound. When a C++ loop terminates, the index variable is typically one greater than the loop's upper bound. However, this is not true of C++ code generated by the MATLAB Compiler.

Refer to your C++ reference manual for more information on how for-loops work in C++.


 Function Calling Conventions Logical Values