C and Matlab Comparison
C and Matlab Comparison
Matlab
C/C++
int i; float x; double x, y; bool flag; char str[25];
Operators Fortran
Exponent Std Math Equals Not Equal Less/Greater than Less/Greater than or equal to Logical not Logical and Logical or Binary and Binary or Increment Decrement Conditional x**y * / + == .eq. /= .ne. < .lt. <= .not. .and. .or. .le.
Matlab
x^y * / + == ~= < > <= >= not and or
C/C++
pow(x, y) * / + == != < > <= >= ! && || & | ++ -(?:)
> >=
.gt. .ge.
Matlab
function ans = myFunction(arg) . . . end
C/C++
int myFunction(double arg) { . . . return ans; } if (i == 0) { . . . } else if (i > 10) { . . . } else { . . . } for (int i = 0; i < n; i++) { . . . continue; //skip to next break; //exit loop } while (i < n) { . . . }
for i = 0:n . . . continue % skip to next break % exit loop end while i < n . . . end