gistlib
Here's the C++ code to define the variable x as 3.5 and increment it by 2:
#include <iostream> int main() { double x = 3.5; x += 2; std::cout << "x = " << x << std::endl; return 0; } 125 chars9 lines
#include <iostream> int main() { double x = 3.5; x += 2; std::cout << "x = " << x << std::endl; return 0; }
In MATLAB, the equivalent code would be:
main.mx = 3.5; x = x + 2; disp(['x = ' num2str(x)]); 47 chars4 lines
x = 3.5; x = x + 2; disp(['x = ' num2str(x)]);
Note that in MATLAB, the disp function is used to display the result.
disp
gistlibby LogSnag