Professional Documents
Culture Documents
Modeliranje I Simulacija
Modeliranje I Simulacija
Mainski faluktet
Modeliranje i simuluacija
Grafiki prikaz u Matlabu
Odradili:
Salkovi Faruk
Omi Elmin
Asistent:
Edis Nasi
x2
x=-20:0.1:20;
>> y=x.*x;
>> plot(x,y)
II primjer:
syms x
>> y=sin(x);
>> z=cos(x);
>> figure(1); ezplot(y)
>> figure(2); ezplot(y); hold on; ezplot(z)
Sin (x)
Cos (x)
Kako
naredba plot?
11
radi
X=[ 1 2 3 4 5 ]
Y=[3 5 7 9 11 ]
plot(X,Y)
11
10
9
8
7
6
5
4
3
1.5
2.5
3.5
4.5
1.5
2.5
3.5
4.5
X=[ 1 2 3 4 5 ]
Y=2*X+1
plot(X,Y)
11
10
9
8
7
6
5
4
3
BOJE
LINIJE
y yellow
m magenta
c cyan
r red
g green
b blue
w white
-.
k black
--
plot(x,y,r:p)
Primjer
plot(X,Y)
hold
Current plot held
plot(X,Y,'ro')
11
10
9
8
7
6
5
4
3
1.5
2.5
3.5
4.5
X=1:10
Y1=2*X+3
Y2=3*X-1
Plot(X,Y1,r.,X,Y1,g:)
30
25
20
15
10
10
Semilogx
semilogy
loglog
Grid
Clf
Clc
Title
Xlabel
Ylabel
Axis
Hold
Hold off
Colordef
Legend
subplot
Primjer
Grafiki predstaviti funkciju z = x2 2xy +3y+2 i njezine konture.
[x,y]=meshgrid(-2:0.1:2, -2:0.1:2);
>> z=x.^2-2*(x.*y)+3*y+2;
>> surf(x,y,z)
>> surf(x,y,z+5); hold on; contour(x,y,z+5,30);
3D grafika
Osnovna naredba za linijske 3D grafove je plot3:
>> t=linspace(0,10*pi);
>> plot3(sin(t),cos(t),t)
>> xlabel('sin(t)'),ylabel('cos(t)'),zlabel('t')
>> title('3D Helix')
1
0.8
0.6
0.4
0.2
0
3
2.5
2
1.5
1
1.5
2.5
x=-10:10;
y=-10:10;
[X,Y]=meshgrid(x,y);
Z=X.^2 + Y.^2;
mesh(Z)