Programming and Graphics

(Kiana) #1

C C++/Matlab/Fortran 77Dictionary 329


Matlab C++

%————– /* ————–
% AUTHOR: J Doe AUTHOR: J Doe
%————– —————- */
int main()
{
No formal structure ...
return 0;
}

Variable declaration float a[30], b[4];
is not required double a[10];
double b[6][68];
Non-positive indices int argos[100];
are not permitted const int WED= 0;

const int dim = 40;
double a[dim];

i=6; % integer int i=6; // integer

a=10.0; % double float a=10.0; // real

b=10.0D0; % double double b=10.0; // double

C=[0.1 0.2. 0.7]; double C[3]={0.1, 0.2, 0.7};

A=[0.1 0.2; -1.0 -0.4]; double A[2][2]={{0.1, 0.2},{-1.0, -0.4}};

B=[0.9 0.4; ... double B[2][2]={{0.9, 0.4}
-3.0 -0.3]; ,{-3.0, -0.3}};

A(1,1)=0.1; A[0][0] = 0.1;

break exit(1);

Table C.2 Matlab/C++ equivalent structures and statements. Statements,
but not variable names, are written in lower case in both languages.

Free download pdf