See best practices for creating and calibrating models, performing simulations, and optimizing code for performance using MATLAB through an example Monte Carlo simulation of interest rate models for counterparty credit risk analysis.