14
Calling C
Both R
and MATLAB can perform vectorized computations, where iteration over the elements of a vector or matrix is performed implicitly, i.e., internally. This is much more efficient than writing explicit “for” loops, which run very slowly due to both platforms being interpreted (rather than compiled) languages. For some computations, however, explicit iteration is required. This occurs when each stage of a computation depends on the results of the previous stage. The following two examples of such computations will be used for demonstration purposes here.
Get R and MATLAB now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.