C++ Programming


Major diffferences between MATLAB and C++

MATLAB C++
Interpretted Compiled
Dynamically-typed Statically-typed
Libraries are optimized, but user-defined code is not as efficient. Can acheive better run-time efficiency.
Built-in support for multi-dimensional data sets and "vectorized" operations. Library support for compound data structures, but no standard form for "vectorized" operations.
Built-in support for graphics/visualization Third-party tools for graphics/visualization


Side-by-side examples

topic MATLAB C++
Function to approximate pi using Taylor series approxPiVectorized.m (vectorized technique)
approxPi.m (using for loop)
approxPi.cpp
Function to compute surface area of a cylinder cylinder.m cylinder.cpp

Compile C++ programs with:

g++ approxPi.cpp -o approxPi
g++ cylinder.cpp -o cylinder