IDL vs. MatLab

Voici quelques commandes courantes sous MatLab et leur équivalent sous IDL.


Commande

MatLab

IDL

Systèmes
Un*x(Solaris, Linux, FreeBSD, IRIX, OS X) et Windows
Lancer le logiciel
matlab / matlab -nojvm
idl / idlde
Equivalence GNU
octave
gdl
Position dans un vecteur
v(2:8)
v[2:8]
Transposition de matrice
M'
TRANSPOSE(M)
Multiplication de matrices
A*B
A##B
Multiplication
A.*B
A*B
Puissance (Matrice)
M^2
M##M
Puissance (Indices)
M.^2
M^2
Ecriture matricielle
M=[2,4,5;5,6,2]
M=[[2,4,5],[5,6,2]]
Extraction submatricielle
M=A(:,:,5:4)
M=A[*,*,5:4]
Somme vectorielle
sum(v)
TOTAL(v)
Somme matricielle
sum(sum(M))
TOTAL(M)
Longueur vectorielle
length(v)
N_ELEMENTS(v)
Réplication scalaire
res=2*ones(T);
res=REPLICATE(2,T,T)
Commentaires
%
;
A la ligne
...
$
Modification de dimensions
b = reshape(a,200,5);
b = REFORM(a,[200,5])
Conditions if
if i == j
   A(i,j) = 2;
elseif abs(i-j) == 1
   A(i,j) = -1;
else
   A(i,j) = 5;
end

IF (i EQ j) THEN BEGIN
   A[i,j] = 2
ENDIF ELSEIF (abs(i-j) EQ 1) BEGIN
   A[i,j] = -1
ENDIF ELSE
A[i,j] = 5
ENDELSE

Boucle for
for k=1:N
x(k) = k;
end

FOR k=1,N DO BEGIN
   x[k]=k
ENDFOR

Conditions matricielles
R=find(toto>3.14)
R=WHERE(toto LT 3.14)
Conversion textuelle
text=num2str(n)
text=STRING(n)
π
pi
!PI ; !DPI
Not a Number
NaN
!VALUES.D.NAN
infinie
inf
!VALUES.D.INFINIY
plus grand que
>
GT
plus grand ou égal à
>=
GE
plut petit que
<
LT
plut petit ou égal à
<=
LE
égal à
==
EQ
différent de
~=
NE
Affichage courbe 2D
plot(x)
plot,x
Affichage matrice
mesh(x)
surface,x
Affichage matrice type surface
surf(x)
shade_surf,x
Suppression de variable
clear toto
clear all
DELVAR,toto
.RESET_SESSION
informations sur une commande
help plot
? plot
enregistrer une variable dans un fichier
file='data.dat';
fid=fopen(file);
fwrite(fid,A,'float32');
fclose(fid);
 OPENW, 1, 'data.dat'
 WRITEU, 1, A







______________________________________________________
06-2009 // A.Lucas  <IPGP>