Documente Academic
Documente Profesional
Documente Cultură
Lab 2
Lab 2
Lab 2
RAPORT
Despre lucrarea de laborator Nr.2
la Mecanică realizată în MATLAB
Chişinău 2018
Scopul lucrării: Însuşirea şi dezvoltarea elementelor de bază de construire a graficelor
în sistemul MATLAB.
Mersul lucrării:
Exerciţiul 1:
Descrieţi comenzile de bază pentru construirea graficelor în pachetul MATLAB.
Exerciţiul 2:
f(x)
20 20 -0.4 2.5
0 15 -0.6
2
ambele pe
-20
10 -0.8
-40
-10 -8 -6 -4 -2 0 2 4 6 8 10
graficul functiei f2=-(x. (1/3)) 5 -1 1.5
0
g(x)
-1 0 -1.2
1
-2
axele din
-5 -1.4
-3
-10 -8 -6 -4 -2 0 2 4 6 8 10 -10 -1.6 0.5
x 10
6 graficul functiei g=((x-1).3 ).*sqrt(x).*(2. x)
3
f(x) şi g(x)
2 -15 -1.8
0
1
-20 -2
0
dreapta
-1 -25 -2.2 -0.5
-10 -8 -6 -4 -2 0 2 4 6 8 10 -10 0 10 -10 0 10 -10 0 10
c2) într-o fereastră – fiecare aparte pe axe diferite şi ambele pe aceleaşi axe.
a)
graficul functiei f2=-(x. (1/3)) x 10
6 graficele functiei 6
x 10 graficele functiei
0 2.5 2.5
f1=2*(x-1) f1=2*(x-1)
ambele pe ambele pe
f2=-(x. (1/3)) 2 f2=-(x.( 1/3))
-0.5
Oy axa ordonatelor
1.5
-1 2
1
-1.5
0.5
Prezentarea graficelor
-2 1.5
0
-2.5 -0.5
-10 -8 -6 -4 -2 0 2 4 6 8 10 -10 -8 -6 -4 -2 0 2 4 6 8 10
Ox axa absciselor
1
6
x 10 graficul functiei g=((x-1).3 ).*sqrt(x).*(2. x) graficul functiei f2=-(x.( 1/3)) 6
x 10 graficul functiei g=((x-1). 3).*sqrt(x).*(2.x )
2.5 0 2.5
2 2
0.5 -0.5
-2
0 0
a) în ferestre diferite
x=[-2*pi:0.05:3*pi];
f=sin(x);
plot (x,f,'g*--');
title('Graficul functiei f');
xlabel ('Axa X');
ylabel ('Axa Y');
legend('Functia 1');
clf reset;
x=[-2*pi:0.05:3*pi];
g=sin(x).*sin(x);
plot (x,g,'r*--');
title('Graficul functiei g');
xlabel ('Axa X');
ylabel ('Axa Y');
legend('Functia 2');
clf reset;
x=[-2*pi:0.05:3*pi];
f=sin(x);
g=sin(x).*sin(x);
plot(x,f,'g*--',x,g,'c+:');
title ('graficul f(x),g(x)');
xlabel ('Axa X');
ylabel ('Axa Y');
legend ('f(x)','g(x)');
c) Prezentarea graficelor folosind comanda subplot.
Orizontal, f(x)
graficul functiei f1=2*(x-1)
20
-20
-40
-10 -8 -6 -4 -2 0 2 4 6 8 10
graficul functiei f2=-(x. (1/3))
0
g(x)
-1
-2
-3
-10 -8 -6 -4 -2 0 2 4 6 8 10
x 10
6 graficul functiei g=((x-1).3).*sqrt(x).*(2. x )
3
f(x) şi g(x)
0
-1
-10 -8 -6 -4 -2 0 2 4 6 8 10
clf reset;
subplot (3,1,1);
x=[-2*pi:0.05:3*pi];
f=sin(x);
plot (x,f,'g*--');
xlabel ('Axa X');
ylabel ('Axa Y');
subplot (3,1,2)
g=sin(x).*sin(x);
plot (x,g,'r+:');
xlabel ('Axa X');
ylabel ('Axa Y');
subplot (3,1,3);
f=sin(x);
g=sin(x).*sin(x);
plot(x,f,'g*--',x,g,'c+:');
title ('graficul f(x),g(x)');
xlabel ('Axa X');
ylabel ('Axa Y');
legend ('f(x)','g(x)');
15
graficul functiei f1=2*(x-1)
-0.4
-0.6
graficul functiei f2=-(x .( 1/3)) graficul
2.5
6
functiei
x 10 g=((x-1).3).*sqrt(x).*(2.x )
2
10 -0.8
ambele pe axele
5 -1 1.5
0 -1.2
1
-5 -1.4
-15 -1.8
din dreapta
0
-20 -2
clf reset;
subplot (1,3,1);
x=[-2*pi:0.05:3*pi];
f=sin(x);
plot (x,f,'g*--');
xlabel ('Axa X');
ylabel ('Axa Y');
subplot (1,3,2)
g=sin(x).*sin(x);
plot (x,g,'r+:');
xlabel ('Axa X');
ylabel ('Axa Y');
subplot (1,3,3);
f=sin(x);
g=sin(x).*sin(x);
plot(x,f,'g*--',x,g,'c+:');
title ('graficul f(x),g(x)');
xlabel ('Axa X');
ylabel ('Axa Y');
legend ('f(x)','g(x)');
c2) Într-o fereastră – fiecare aparte pe axe diferite şi ambele pe aceleaşi axe.
f(x)
graficul functiei f2=-(x. (1/3)) x 10
6
graficele functiei
0 2.5
f1=2*(x-1)
-0.5 f2=-(x.( 1/3))
-1 2
-1.5
-2 1.5
Oy axa ordonatelor
-2.5
-10 -8 -6 -4 -2 0 2 4 6 8 10
1
6
x 10 graficul functiei g=((x-1).3 ).*sqrt(x).*(2. x)
2.5
2
0.5
1.5
1
0
0.5
-0.5 -0.5
-10 -8 -6 -4 -2 0 2 4 6 8 10 -10 -5 0 5 10
Ox axa absciselor
ambele pe axele din dreapta f(x) şi g(x)
g(x)
clf reset;
subplot (2,2,1);
x=[-2*pi:0.05:3*pi];
f=sin(x);
plot (x,f,'g*--');
subplot (2,2,3)
g=sin(x).*sin(x);
plot (x,g,'r+:');
subplot (1,2,2);
f=sin(x);
g=sin(x).*sin(x);
plot(x,f,'g*--',x,g,'c+:');
legend ('f(x)','g(x)');
f(x) şi g(x)
6
x 10 graficel e functiei
2.5
f1=2*(x-1)
2 f2=-(x. (1/3))
Oy axa ordonatelor
1.5
0.5
2
-0.5
1.5
-1
1
-1.5
0.5
-2
0
-2.5 -0.5
-10 -5 0 5 10 -10 -5 0 5 10
f(x) g(x)
clf reset;
subplot (2,2,3);
x=[-2*pi:0.05:3*pi];
f=sin(x);
plot (x,f,'g*--');
subplot (2,2,4)
g=sin(x).*sin(x);
plot (x,g,'r+:');
subplot (2,1,1);
f=sin(x);
g=sin(x).*sin(x);
plot(x,f,'g*--',x,g,'c+:');
legend ('f(x)','g(x)');
Exerciţiul 3:
Metoda Mesh
[x,y]=meshgrid (0:0.05:2*pi,0:0.05:1);
z=sin(x).*exp(-3.*y);
figure(1);
mesh (x,y,z);
title('Mesh');
Metoda Surf
>> figure(2);
>> surf(x,y,z);
>> title('Surf');
Metoda Meshc
>> figure(3);
>> meshc(x,y,z);
>> title('Meshc');
Metoda Surfc
>> figure(4);
>> surfc(x,y,z);
>> title('Sufc');
Metoda Contour
>> figure(5);
>> contour(x,y,z);
>> title('Contour');
Metoda Contourf
>> figure(6);
>> contourf(x,y,z);
>> title('Contourf');
Metoda Contour3
>> figure(7);
>> contour3(x,y,z);
>> title('Contour3');
Concluzie: