)
Comparison of Syntax and Functions between Ch® and MATLAB®
The brief systax comparison of MATLAB and Ch below highlights how code written in mathematical software packages such as MATLAB can be easily ported to run in Ch. Ch follows conventional mathematics within the framework of ISO C/C++ standards. Some operators such as '\' not commonly used in conventional mathematics are excluded in Ch to avoid confusion for learners.

Symbols Used in Comparison of Ch and MATLAB.

Symbol Data Type
x scalar or computational array of real or complex type.
A, Ai, B, Bi computational arrays of real or complex type.
Av, Avi, Bv, Bvi one-dimensional computational arrays of real or complex type.
R, Ri computational arrays of real type.
Rv, Rvi one-dimensional computational arrays of real type.
I, Ii computational arrays of integral type.
Iv,Ivi one-dimensional computational arrays of integral type.
C, Ci arrays of char type.
Z, Zi computational arrays of complex type.
Zv, Zvi one-dimensional computational arrays of complex type.
s scalar of real or complex type.
z scalar complex type.
r scalar real type.
f scalar floating-point type.
i scalar integral type.
p pointer type.
str a string.

Comparisons of metanumbers in MATLAB and Ch

MATLAB Ch
-0, +0, Inf, -Inf, NaN -0.0, +0.0, Inf, -Inf, NaN, ComplexInf, ComplexNaN
Comparisons of Operators in MATLAB and Ch.

Operators MATLAB Ch
~ ~A !A
~s !s
+ +A +A
+s +s
- -A -A
-s -s
> A > B A > B
A > s A > r
s > A s > A
>= A >= B A >= B
A >= s A >= r
s >= A r >= A
== A == B A == B
A == s A == s
s == A s == A
<= A <= B A <= B
A <= s A <= r
s <= A r <= A
< A < B A < B
A < s A < r
s < A r < A
~= A ~= B A != B
A ~= s A != s
s ~= A s != A
| A | B A || B
A | s A || r
s | A r || A
& A & B A && B
A & s A && s
s & A s && A
+ A+B A+B
A+s A+s
s+A s+A
A = A+B A = A+B
A = A+B A += B
- A-B A-B
A-s A-s
s-A s-A
A = A-B A = A-B
A = A-B A -= B
* A*B A*B
A*s A*s
s*A s*A
A = A*B A = A*B
A = A*B A *= B
/ A = A1/B1A=A1*inverse(B1)
A/s A/s
A = A/s A = A/s
A = A/s A /= s
^ i1^i2 pow(i1,i2)
s1^s2 pow(s1,s2)
I^i pow(I,i)
A^i pow(A,i)
\ A=A1\B1 A=inverse(A1)*B1
\ Av=A\Bv' linsolve(Av,A,Bv)
Av=inverse(A)*Bv
llsqsolve(Av,A,Bv)
' A' transpose(A)
' Z' transpose(conj(Z))
.* A .* B A .* B
./ A ./ B A ./ B
./ s ./ A s ./ A
.^ A.^B pow(A, B)
.^ A.^s pow(A, (array double [n])s)
.^ s.^A pow((array double [n])s, A)
.\ A.\B (not valid)
Column m(:,j) shape(m,0)
Row m(i,:) shape(m,1)
List Variables whos showvar

Comparisons of Functions in MATLAB and Ch
Functions MATLAB Ch
abs r=abs(s) r=abs(s)
r=abs(A) r=abs(A)
Iv=abs('str') array int Iv[strlen("str")+1]={'s','t','r'}
acos x=acos(x) x=acos(x)
acosh x=acosh(x) x=acosh(x)
all i=all(A) i=sum(!A=0)==0
angle r=angle(z) r=carg(z)
any i=any(A) i=sum(A!=0)!=0
asin x=asin(x) x=asin(x)
asinh x=asinh(x) x=asinh(x)
atan x=atan(x) x=atan(x)
atan2 r=atan2(r1,r2) r=atan2(r1,r2)
atanh x=atanh(x) x=atanh(x)
balance [A, B] = balance(A1) balance(A1, A, B)
base2dec i=base2dec('str',i2) i=strtol("str", NULL, i2)
blanks str=blank(n) " "
break break break
ceil x=ceil(x) s=ceil(s)
choly A = chol(A1) choldecomp(A1, A)
clear clear name remvar name
clear name #pragma remvar(name)
compan A=compan(Av) R=companionmatrix(Rv)
Z=ccompanionmatrix(Zv)
cond r=cond(A) r=condnum(A)
condest r=condest(A) r=condnum(A)
conj x=conj(x) x=conj(x)
conv Av = conv(Av1, Av2) conv(Av, Av1, Av2)
conv2 A = conv2(A1, A2) conv2(A, A1, A2)
corr2 r = corr2(R1, R2) r = correlation2(R1, R2)
corrcoef R = corrcoef(R1) corrcoef(R, R1)
cos x=cos(x) x=cos(x)
cosh x=cosh(x) x=cosh(x)
cov R = cov(R1) covariance(R, R1)
cross Rv=cross(Rv1,Rv2) Rv=cross(Rv1,Rv2)
cumprod A = cumprod(A1') cumprod(A, A1)
A = cumprod(A1) cumprod(A, trasnpose(A1))
Av =cumprod(Av1) cumprod(Av, Av1)
cumsum A = cumsum(A1') cumsum(A, A1)
A = cumsum(A1) cumsum(A, trasnpose(A1))
Av =cumsum(Av1) cumsum(Av, Av1)
dec2bin i=dec2bin(i2) printf(%b", i2)
printf(%10b", i2)
dec2hex str=dec2hex(x) sprintf(str,"%x", r)
deconv A=deconv(A1,B1) deconv(A,A1,B1)
[A, B]=deconv(A1,B1) deconv(A,A1,B1,B)
deblank() deblank('str') (not valid)
det s=det(A) r=determinant(A)
z=cdeterminant(Z)
diag Av=diag(A) Rv=diagonal(R)
Zv=diagonal(Z)
A=dia(Av) R=diagonalmatrix(Rv)
Z=cdiagonalmatrix(Zv)
diff A=diff(A) Rv=difference(Rv)
r=derivative(func,r)
R=derivatives(func,R)
dot x=dot(Av1,Av2) r=dot(Rv1,Rv2)
eig Av=eig(A1) eigen(A1, Av, NULL)
[Av, B]=eig(A1) eigen(A1, Av, B)
[Av, B]=eig(A1,'nobalance') eigen(A1, Av, B, "nobalance")
eps eps #include <float.h>
FLT_EPSILON, DBL_EPSILON
eval eval('cmd') system("cmd")
eval('expr') streval("expr")
eval(try,catch)
eye R=eye(i) R=identitymatrix(i)
exp x=exp(x) x=exp(x)
expm A = expm(A1) expm(A,A1)
fclose fclose see fclose()
feval feval('fun') streval("fun")
feof feof see feof()
ferror ferror see perror() and other I/O functions
fft Av = fft(Av1) fft(Av, Av1)
Av = fft(Av1, i) A = fft(A1, i)
fft2 A=fft2(A1) fft(A, A1)
A = fft(A1, i1, i2) Iv[0]=i1, Iv[1] =i2, A = fft(A1, Iv)
fftn A=fftn(A1) fft(A, A1) /* 3D only */
A = fftn(A1, i) Iv[0]=Iv[1]=Iv[2]=i, fft(A,A1,Iv) /* 3D only */
fgetl str = fgetl(fid) i=strlen(str)
getline(fid, str, i)
fgets fgets see fgets()
fix i=fix(r) i=r
filter Av = filter(Bv1, Bv2, Av1) filter(Bv1, Bv2, Av1, Av)
filter2 A = filter2(A1, B1) filter2(A, A1, B1)
finite i=finite(s) i=isfinite(s)
I=finite(A) fevalarray(I,isfinite,R);
find() i=find(x)
[r,c]=find(x)
I = find(A) i=findvalue(I, A) /* i is # of values found */
findstr() i=findstr('str1', 'str2') p=strstr(str1, str2)
fliplr A = fliplr(A1) fliplr(A, A1)
flipud A = flipud(A1) flipud(A, A1)
floor floor(x) floor(x)
flops flops (Not valid)
fmin r = fmin('fun', r1, r2) fminimum(&r3, &r, fun, r1, r2)
fmins Rv = fmins('fun', Rv1) fminimums(&r3, Rv, fun, Rv1)
fplot fplot('fun', [r1 r2]) fplotxy(fun,r1,r2)
fplotxyz()
CPlot:memberFunctions()
fprintf fprintf() see fprintf()
frewind frewind() see frewind()
fscanf fscanf() see fscanf()
fseek fseek() see fseek()
ftell ftell() see ftell()
funm R = funm(R1,'fun') funm(R, fun, R1)
Z = funm(Z,'fun') cfunm(Z, /* complex */ cfun, Z1)
fwrite fwrite() see fwrite()
fsolve R =fsolve('fun', Ri) fsolve(R, fun, Ri)
fzero r = fzero('fun', r1) fzero(&r, fun, r1)
gallery A=gallery(name,arg1) A=specialmatrix(Name,arg1)
A=gallery(name,arg1,agr2) A=specialmatrix(Name,arg1,arg2)
A=gallery(name,arg1,agr2,arg3) A=specialmatrix(Name,arg1,arg2,arg3)
A=gallery('caychy',Av1) specialmatrix("Cauchy",Av1)
A=gallery('caychy',Av1,Av2) specialmatrix("Cauchy",Av1,Av2)
A=gallery('chebvand',Av1) specialmatrix("ChebyshevVandemonde",Av1)
A=gallery('chebvand',i,Av1) specialmatrix("ChebyshevVandemonde",Av1,i)
A=gallery('chow',i) specialmatrix("Chow",i)
A=gallery('chow',i,r1) specialmatrix("Chow",i,r1)
A=gallery('chow',i,r1,r2) specialmatrix("Chow",i,r1,r2)
A=gallery('circul',Av1) specialmatrix("Circul",Av1)
A=gallery('clement',i1,i2) specialmatrix("Clement",i1,i2)
specialmatrix("DenavitHartenberg",r1,r2,r3,r4)
specialmatrix("DenavitHartenberg2",r1,r2,r3,r4)
A=gallery('fiedler',Av1) specialmatrix("Fiedler",Av1)
A=gallery('frank',i1) specialmatrix("Frank",i1)
A=gallery('frank',i1,i2) specialmatrix("Frank",i1,i2)
A=gallery('gearmat',i1) specialmatrix("Gear",i1)
AV=gallery('house',Av1) householdermatrix(Av1,Av)
[AV,r]=gallery('house',Av1) householdermatrix(Av1,Av,r)
A=gallery('wilk',i1) specialmatrix("Wilkinson",i1)
gcd() I = gcd(I1, I2) gcd(I1, I2, I)
[I,I3,I4]=gcd(I1,I2) gcd(I1, I2, I, I3, I4)
hankel A=hankel(Av1) specialmatrix("Hankel",Av1)
A=hankel(Av1,Av1) specialmatrix("Hankel",Av1,Av2)
hex2dec i=hex2dec('str') i=strtol("str", NULL, 16)
hex2num() r=hex2num('str')
hess [B, A] = hess(A1) hessdecomp(A1, A, B)
hilb() A=hilb(i1) specialmatrix("Hilbert",i1)
hist hist() histogram()
i i #include <complex.h>
I
ifft Av=ifft(Av1) ifft(Av, Av1)
Av=ifft(Av1, i) ifft(A, A1, i)
ifft2 A=ifft2(A1) ifft(A,A1)
A = ifft(A1, i1, i2) Iv[0]=i1, Iv[2] =i2, ifft2(A, A1, Iv)
ifftn A=ifftn(A1) ifft(A, A1) /* 3D only */
A = iftn(A1, i) Iv[0]=Iv[1]=Iv[2]=i, ifft(A, A1,Iv)
imag r=imag(s) r=imag(s)
R=imag(A) R=imag(A)
inf inf Inf
input s=input(str) r=getnum(str,r)
int2str str=int2str(i) sprintf(str,"%s", i)
interp1 Ri=interp1(R1, R2, Ri1) interp1(Ri, Ri1, R1, R2, "linear")
Ri=interp1(R1, R2, Ri1,'linear') interp1(Ri, Ri1, R1, R2, "linear")
Ri=interp1(R1, R2, Ri1,'spline') interp1(Ri, Ri1, R1, R2, "spline")
interp2 Ri=interp2(R1, R2, R3, Ri1, Ri2) interp2(Ri, Ri1, Ri2, R1, R2, R3, "linear")
Ri=interp2(R1, R2, R3, Ri1, Ri2, 'linear') interp2(Ri, Ri1, Ri2, R1, R2, R3, "linear")
Ri = interp2(R1, R2, R3, Ri1, Ri2, 'spline') interp2(Ri, Ri1, Ri2, R1, R2, R3, "spliine")
inv A=inv(A) R=inverse(R)
Z=cinverse(Z)
invhilb A=invhilb(i1) specialmatrix("InverseHilbert",i1)
isempty i=isempty(A) (not valid)
isglobal i=isglobal(x) #include <chshell.h>
isvar("x")==CH_SYSTEMVAR
ishold i=ishold (not valid)
isieee i=isieee (not valid)
isinf i=isinf(s) i=isinf(s)
I=isinf(A) fevalarray(I,isinf,R);
isletter i=isletter(s) i=isalpha(s)
I=isletter(A) fevalarray(I,isalpha,R);
isnan i=isnan(s) i=isnan(s)
I=isnan(A) fevalarray(I,isnan,R);
isreal i=isreal(s) i=elementtype(x) != elementtype(complex) &&
elementtype(x) != elementtype(double complex)
isspace i=isspace(s) i=isspace(s)
I=isspace(A) fevalarray(I,isspace,R);
issparse i=issparse(x)
isstr i=isstr(x) i=elementtype(x)==elementtype(string_t)
isstudent i=isstudent i=isstudent()
isunix i=isunix #ifndef _WIN32_
isvms i=isvms (not valid)
invhilb()
j j #include <complex.h>
I
lasterr lasterr('') see perror(), strerror()
lcm() I = lcm(I1,I2) lcm(I,I1,I2)
length i=length(A) i=max(shape(A))
linspace x=linspace(first,last,n) linspace(x,first,last)
loglog loglog(x, y) plot.loglog(x,y)
logspace x=logspace(first,last,n) logspace(x,first,last)
log x=log(x) x=log(x)
log10 x=log10(x) x=log10(x)
log2 x=log2(x) x=log(x)/log(2)
r=log2(r) r=log2(r)
logm A=logm(A1) logm(A,A1)
lower str=lower('str') see tolower()
lscov() R = lscov(A1,R1,A2) llsqcovsolve(A1,R1,A2,R)
[R,R2]=lscov(A1,R1,A2) llsqcovsolve(A1,R1,A2,R,R2)
lu [R1,R2]=lu(A) ludecomp(A,R1,R2)
[R1,R2,I]=lu(A) ludecomp(A,R1,R2,I)
magic() A=magic(i1) specialmatrix("Magic",i1)
max r=max(s1,s2) r=max(r1,r2)
r=max(Av) r=max(R)
Rv=max(A) Rv=maxv(R)
Rv=transpose(maxv(transpose(R))
min r=min(s1,s2) r=min(r1,r2)
r=min(Av) r=min(R)
Rv=min(A) Rv=minv(R)
Rv=transpose(minv(transpose(R))
mean r=mean(R) r=mean(R)
Rv=mean(R) r=mean(R, Rv)
mean(transpose(R), Rv)
z = mean(Z) z = cmean(Z)
Zv = mean(Z) cmean(Z, Zv)
median r=median(R) r=median(R)
Rv=median(R) r=median(R, Rv)
median(transpose(R), Rv)
mod i=mod(i1,i2) i=i1%i2
r=mod(r1,r2) r=fmod(r1,r2)
NaN NaN NaN
nargin nargin (not valid)
nargout nargout (not valid)
nextpow2 i=nextpow2(r) i=ceil(log2(r))
i=nextpow2(z) i=ceil(log2(abs(z)))
i=nextpow2(Av) i=ceil(log2((int)shape(Av)))
nnls() R=nnls(A1,R1) llsqnonnegsolve(A1,R1,R)
R=nnls(A1,R1,r) llsqnonnegsolve(A1,R1,R,r)
[R,R2]=nnls(A1,R1) llsqnonnegsolve(A1,R1,R,0.0,R2)
[R,R2]=nnls(A1,R1,r) llsqnonnegsolve(A1,R1,R,r,R2)
norm norm(A) norm(A,"2")
norm(A,1) norm(A,"1")
norm(A,2) norm(A,"2")
norm(A,inf) norm(A,"i")
norm(A,'fro') norm(A,"f")
norm(Av) norm(Av,"2")
norm(Av,inf) norm(Av,"i")
norm(Av,-inf) norm(Av,"-i")
norm(Av,p) norm(Av,"p")
num2str str=num2str(s) sprintf(str,"%s", s)
null A=null(Ai) nullspace(Ai, A)
ones ones(i1) (array int a[i1][i1])1
ones(i1,i2) (array int a[i1][i2])1
ones(size(A)) array int dim[2]=shape(A);
(array int a[dim[0]][dim[1]])1
ode23 [Rv1,Rv2]=ode23('fun',r1,r2,Rv) odesolve(Rv1,Rv2,fun,r1,r2,Rv)
ode45 [Rv1,Rv2]=ode45('fun',r1,r2,Rv) odesolve(Rv1,Rv2,fun,r1,r2,Rv)
orth A = orth(Ai) orthonormalbase(Ai, A)
pascal() A=pascal(i1) specialmatrix("Pascal",i1)
A=pascal(i1,i2) specialmatrix("Pascal",i1,i2)
pi pi #include <math.h>
M_PI
pinv A1=pinv(A) R1=pinverse(R)
poly Av=poly(A) charpolycoef(Av,A)
Bv=poly(Av) polycoef(Bv,Av)
polyder Av = polyder(Bv) polyder(Av, Bv)
polyder2 Av = polyder(Av1, Bv1) polyder2(Av, NULL, Av1, Bv1)
[Av, Bv] = polyder(Av1, Bv1) polyder2(Av, Bv, Av1, Bv1)
polyfit Rv=polyfit(Rv1, Rv2, i) polyfit(Rv, Rv1, Rv2)
polyval r = polyval(Rv1, r1) r = polyeval(Rv1, r1)
r = polyval(Rv1, r1, Rv) r = polyeval(Rv1, r1, Rv)
z = polyval(Av1, s) z = cpolyeval(Av1, s)
z = polyval(Av1, s, Av) z = cpolyeval(Av1, s, Av)
Av = polyval(Bv, Av1) polyevalarray(Av, Bv, Av1)
A=polyval(Av,A1) polyeval(A,Av,A1)
polyvalm() A=polyvalm(Av,A1) polyevalm(A,Av,A1)
plot plot(Rv1,Rv2) plotxy(Rv1,Rv2)
plotxyf(file)
CPlot:memberFunctions()
plot3 plot3(Rv1,Rv2,Rv3) plotxyz(Rv1,Rv2,Rv3)
plotxyzf(file)
CPlot:memberFunctions()
prod s=prod(A) r=product(R)
z=cproduct(Z)
Av=prod(A) r=product(R, Rv)
Av=prod(A, 1) r=product(R, Rv)
Av=prod(A, 2) r=product(transpose(R), Rv)
z=cproduct(Z,Zv)
product(transpose(R), Rv)
cproduct(transpose(Z), Zv)
qr [A1, A2] = qr(A) qrdecomp(A, A1, A2)
[A1, A2, A3] = qr(A)
[A1,A2]=qr(A,0) qrdecomp(A,A1,A2)
qrdelete [A1, B1] = qrdelete(A, B, j) qrdelete(A1, B1, A, B, j)
qrinsert [A1, B1] = qrinsert(A, B, j, Av) qrinsert(A1, B1, A, B, j, Av)
rank i = rank(A) i = rank(A)
i = rank(A, r) i = rank(A)
real r=real(s) r=real(s)
R=real(A) R=real(A)
realmax realmax #include <float.h>
FLT_MAX, DBL_MAX
realmin realmin #include <float.h>
FLT_MIN, DBL_MIN
rem r=rem(r1,r2) r=fmod(r1,r2)
r=remainder(r1,r2)+r2
residue [Av,Bv,Rv]=residue(Rv1,Rv2) residue(Rv1, Rv2, Av, Bv, Rv)
round i=round(r) i=round(r)
roots Av=roots(Bv) roots(Av,Bv)
rosser A=rosser() specialmatrix("Rosser")
rot90(A) A = rot90(A1) rot90(A,A1)
A = rot90(A1,i) rot90(A,A1,i)
rand r=rand() r=urand()
randn R=rand(i1, i2) urand(R)
rcond r = rcond(A) r = rcondnum(A)
reshape reshape(A, m, n) (array type [m][n])A
rsf2csf [A1, B1] = rsf2csf(A, B) rsf2csf(A1, B1, A, B)
schur A1 = schur(A) schurdecomp(A, A1, NULL)
[A1, A2] = schur(A) schurdecomp(A, A1, A2)
semilogx semilogx(x, y) plot.semilogx(x,y)
semilogy semilogy(x, y) plot.semilogy(x,y)
sign i=sign(r) i=sign(r)
z=sign(z) z=z/abs(z)
sqrt x=sqrt(x) x=sqrt(x)
sqrtm A = sqrtm(A1) sqrtm(A,A1)
size Iv=size(A) Iv=shape(A)
[i1,i2]=size(A) Iv=shape(A); i1=Iv[0]; i2=Iv[1]
i=size(A,1) i = (int)shape(A)
i=size(A,2) Iv=shape(A); i=Iv[1]
sort Av=sort(Av1) sort(Av, Av1)
sort(Av, Av1, "array")
A=sort(A1) sort(A, A1, "column")
A=sortrows(A1) sort(A, A1, "row")
[Av, I]=sort(Av1) sort(Av, Av1, "array", I)
sort(Av, Av1, NULL, I)
[A, I]=sort(A1) sort(A, A1, "column", I)
[A, I]=sortrows(A1) sort(A, A1, "rows", I)
spline Ri = spline(R1, R2, Ri1) interp1(Ri, R1i, R2i, "spline")
ri = spline(R1, R2, r) CSpline::Interp(r)
Ri = spline(R1, R2, Ri1) CSpline::Interpm(Ri1, Ri)
sprintf sprintf() see sprintf()
sscanf sscanf() see sscanf()
std r=std(R) r=std(R)
Rv=std(R) r=std(R, Rv)
std(transpose(R), Rv)
str2mat C=str2mat('str1', 'str2', ...) str2mat(C, str1, str2)
str2num i=str2num('str') i=atol(str), see strtod()
strcmp strcmp('str1','str2') !strcmp("str1","str2")
strrep str = strrep('str1', 'str2', 'str3') str=strrep(str1, str2, str3)
strtok strtok see strtok(), strtok_r()
subplot subplot() CPlot::subplot()
CPlot::getSubplot()
sum r=sum(A) r=sum(R)
z=csum(Z)
Av=sum(A) r=sum(R, Rv)
z=csum(Z,Zv)
sum(transpose(R), Rv)
csum(transpose(Z), Zv)
svd R = svd(A) svd(A, R, NULL, NULL)
[A1, R, A2] = svd(A)) svd(A, R, A1, A2)
tan x=tan(x) x=tan(x)
tanh x=tanh(x) x=tanh(x)
toeplitz A=toeplitz(Av1) specialmatrix("Toeplitz",Av1)
A=toeplitz(Av1,Av2) specialmatrix("Toeplitz",Av1,Av2)
trace s=trace(A) r=trace(R)
z=ctrace(Z)
trapz r=trapz(Rv1,Rv2) see integral1()
tril A1=tril(A) A1=triangularmatrix("lower",A)
Z1=tril(Z) Z1=ctriangularmatrix("lower",Z)
A1=tril(A,i) A1=triangularmatrix("lower",A,i)
Z1=tril(Z,i) Z1=ctriangularmatrix("lower",Z,i)
triu A1=triu(A) A1=triangularmatrix("upper",A)
Z1=triu(Z) Z1=ctriangularmatrix("upper",Z)
A1=triu(A,i) A1=triangularmatrix("upper",A,i)
Z1=triu(Z,i) Z1=ctriangularmatrix("upper",Z,i)
vander R=vander(Rv) R=vandermatrix(Rv)
A=vander(Av) specialmatrix("Vandermonde", Av)
unwrap() A=unwrap(A1) unwrap(A,A1)
A=unwrap(A1,r) unwrap(A,A1,r)
upper str=upper('str') see toupper()
who who stackvar
xcorr Av = xcorr(Av1, Av2) correlation(Av, Av1, Av2)
xor xor(A,B) A ^^ B
xor(A,s) A ^^ r
xor(s,A) r ^^ A
zeros zeros(i1) (array int a[i1][i1])0
zeros(i1,i2) (array int a[i1][i2])0
zeros(size(A)) array int dim[2]=shape(A);
(array int a[dim[0]][dim[1]])0

Control Flow Comparison Between MATLAB and Ch

descriptionsMATLAB Ch
for-loop For n=n1:n2:n3
commands
end
for (n=n1; n<=n3; n+=n2) {
commands
}
while-loopwhile expr
commands
end
while(expr) {
commands
}
ifif expr
commands
end
if (expr) {
commands
}
if-elseif expr1
commands1

else
commands2
end
if (expr1) {
commands1
}
else{
commands2
}
if-else if-elseif expr1
commands1

elseif expr2
commands2

else
commands3
end
if (expr1) {
commands1
}
else if(expr2) {
commands2
}
else {
commands3
}

More features:

References:

• The Ch Language Environment, --- User's Guide, Version 2.0, Harry H. Cheng, SoftIntegration, Inc., September 2001.
• The Ch Language Environment, --- Reference Guide, Version 2.0, SoftIntegration, Inc., September 2001.
• MATLAB Function Reference, Version 6, The MathWorks, Inc., 2001.
MATLAB® is a registered trademark of The MathWorks, Inc. Motif® is a registered trademark of the Open Group. OpenGL® is a registered trademark of SGI.