티스토리 뷰
// kick off : 2016-10-30
// by Ryan C
I am writing this for comparison of the syntax of the three most popular programming languages. This will be useful for the people who interchangeably use those languages but having painful time to recall the grammar of each language.
|
python |
matlab |
c++ |
continue code next line | \ |
... |
(nothing. just enter) |
end of the sentence |
(nothing) |
(nothing) for echo ; for non-echo |
; |
block |
indent |
"end" e.g.) function for ... end end |
{} |
function |
def f1(arg1, arg2) : return arg1+arg2 |
function [ a, b ] = f1(arg1, arg2) a = arg1 + arg2; b = arg1 * arg2; end |
int f1(arg1, arg2) { return arg1 + arg2; } |
OOP |
yes (in case you want to return multiple variables you would use an object that has a structure inside) |
no (that's why it should have multiple return variables as above, a, and b.) |
yes (same as python) |
variable type | implicit | implicit | explicit (need to define) |
comment (single line) | # | % | // |
comment (multiple lines) | """ .... """ | n.a. (just use % every line) | /* ... */ |
open new file | edit f1 % it gives f1.m newly opened for you | ||
differentiate | syms t diff(cos(t)^2, t) | ||
Matrix calculation |
|
Suppose you have an 7x7 matrix cf. X^2 := X*X |