Useful Matlab's functions

From GHER

Jump to: navigation, search

Functions ==> Actions
Syntaxe


Contents

General


uread ==> read

x = uread('Calvi.X')

Type ==> affiche contenu

Type fonction

Which ==> where is a command ?

which commande

Edit ==> launching text editor

edit

'; '==> don't screening results

commandX;

Whos ==> Check of all variables in workspace

whos

Clear ==> Clean a variable

clear ans

Diary ==> Create a diary of your Matlab in disk file

diary filename



Matrix


A(3,2) ==> A matrice See the 2nd element of the 3rd row

A(3,2)
A(3,2) = 30

A(3,2) = 30 ==> Replace the 2nd element of the 3rd row by 30

A(3,1:4) = [1 3 3 5]

Replace the 3rd row by [...,..,..]


a:b ==> go a to b

c = o : 10
c =o 1 2 3 4 5 6 7 8 9 10
c = 1 : 0.5 : 10
Go 1 to 10 with an increment of 0.5
C = 1 : 0.5 : 10

' ==> tranposed

M'

.* ==> Elements multipliate between us

A.*B

example : A.^2 squares each element of the matrix


% ==> comments


Load ==>Load a file

load filename.txt

Save ....mat ==>Save and include in workspace (fichier binaire)

save test_new.mat
Nomscript.m



Help


Help ==> informations about command or scripts

help scriptname

helpwin elfun ==> listing of elementary functions


helpwin specfun ==> listing of specialised functions


helpwin elmat ==> matrix functions


helpwin punct ==> specialised characters



Graphics


  • Plot ==> a line graphic

Plot ==> plotting when 2 vectors have the same lenght (y=f(y))

plot (x,y)

Plot 'r-' 'r--' ==> Plot y1 en rouge pointillé ('r--') et y2 en bleu continu ('b-') plot (x, y1, 'r--', x,y2, 'b-')


Plot just a point

plot(....,'k*'...) 

figure ==> Creer une autre fenetre de plot

plot (x,y1,'r--')
figure
plot (x,y2,'b--')

clf ==> clear figures


hold ==> add plots on the same figure

plot (x,y1,'r--')
hold on            %ouvre
bar (x,y2)
hold off           %ferme



Subplot ==> plotting many figures in parallel in a same window

subplot (m, n, p) : 
m : nombre de division en ligne
n : nombre de division verticale
p : régio active pour le graphe

subplot (2,1,1), plot (x, y1, 'r--')

subplot (2,1,2), plot (x, y2)


Axis ==>Scaling of the axis >> plot (x,y1,'r--') >> axis ([xmin xmax ymin ymax]) Axis square


Axes carrés >> axis square


Title ==> put a title

title('c est bidon')

Xlabel ylabel ==> name axis

xlabel ('x-axis')
ylabel ('bibi')

grid ==> put a grid

grid

  • bar ==> do histogram

  • pcolor ==> do an area graph

don't forget to transpose matrix ...

pcolor(A'), shading flat, colorbar

for more informations go to http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/matlab_env/f8-29401.html&http://www.mathworks.com/access/helpdesk/help/techdoc/learn_matlab/f0-20316.html



Functions


Path ==> search functions

path

Set path ==> see or modify a function

Set Path


Some about Octave

Wikibook about Octave : http://fr.wikibooks.org/wiki/Octave


help -i : for help


look for keywords : find function according keywords


pkg load yapso : launch Yapso


pkg unload yapso : to close yapso close


pcolor (variable) : plot 'variable'


variable' : transpose variable


colorbar : display the color bar


ncdump -h filename.ext : donne ce qu'il y a dans le fichier






As Linux command


Dir = ls

Type = cat

Delete = rm

Cd = cd

Personal tools