Documente Academic
Documente Profesional
Documente Cultură
al Republicii Moldova
Departamentul Fizica
RAPORT
despre lucrarea de laborator Nr. 2
la Mecanică realizată în MATLAB
Chişinău 2020
Scopul lucrării: Însuşirea elementelor 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
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)
0 -1.2
-1
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
2
-0.5 f2=-(x. (1/3)) f2=-(x.( 1/3))
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)) x 10
6 graficul functiei g=((x-1). 3).*sqrt(x).*(2.x )
2.5 0 2.5
2 2
0.5 -0.5
in ferestre diferite:
1.5 1.5
dreapta sus
-1
1 1
0 -1.5
0.5 0.5
-2
0 0
a) în ferestre diferite
>> x=[-1:0.1:1];
>> f=(x.^3)+2.*(x.^2)+1;
>> figure (1)
>> g=(x-1).^4;
>> plot(x,f,'gx:');
>> title('Graficul functiei f');
>> xlabel('Axa x');
>> ylabel('Axa y');
>> legend('Functia 1')
clf reset;
x=[-1:0.1:1];
f=(x.^3)+2.*(x.^2)+1;
g=(x-1).^4;
plot(x,g,'b^-.');
title('Graficul functiei g');
xlabel('Axa x');
ylabel('Axa y');
legend('Functia 2')
clf reset;
hold on;
x=[-1:0.1:1];
f=(x.^3)+2.*(x.^2)+1;
g=(x-1).^4;
figure(1);
plot(x,f,'gx:');
plot(x,g,'b^-.');
xlabel('Axa x');
ylabel('Axa y');
title('Graficul functiilor f si g');
legend('Functia 1','Functia 2')
0
graficul functiei f1=2*(x-1)
-20
-40
-10 -8 -6 -4 -2 0 2 4 6 8 10
graficul functiei f2=-(x. (1/3))
g(x)
0
-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) 1
-1
-10 -8 -6 -4 -2 0 2 4 6 8 10
x=[-1:0.1:1];
f=(x.^3)+2.*(x.^2)+1;
g=(x-1).^4;
figure (1)
subplot(3,1,1)
plot (x,f,'g:^')
legend ('f(x)')
subplot (3,1,2)
plot (x,g,'r-*')
legend ('g(x)')
subplot(3,1,3)
hold on
plot (x,f,'g:^')
plot (x,g,'r-*')
legend('f(x)','g(x)');
15 -0.6
2
10 -0.8
ambele pe axele 5
0
-1
-1.2
1.5
1
-5 -1.4
din dreapta
-15 -1.8
0
-20 -2
figure (2)
subplot (1,3,1)
plot (x,f,'g:^')
title ('Graficul
functiei f(x)')
legend ('g(x)')
subplot(1,3,2)
plot (x,f,'g:^')
plot (x,g,'r-*')
title ('Graficul
functiei g(x)')
legend ('g(x)')
subplot (1,3,3)
hold on
plot (x,f,'g:^')
plot (x,g,'r-*')
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)
-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
figure (3)
subplot(2,2,1);
plot(x,f,'g-d')
xlabel('X');
ylabel ('Y');
legend('f(x)');
subplot(1,2,2);
hold on
plot(x,f,'g-d')
plot(x,g,'b:o')
xlabel('X');
ylabel('Y');
legend('f(x)','g(x)');
subplot(2,2,3);
plot(x,g,'b:o')
xlabel('X');
ylabel('Y');
legend('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
-0.5
-10 -8 -6 -4 -2 0 2 4 6 8 10
Ox axa absciselor
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)
figure (4)
subplot(2,1,1);
hold on
plot(x,f,'g-d')
plot(x,g,'b:o')
xlabel('X');
ylabel('Y');
legend('f(x)','g(x)');
subplot(2,2,3);
plot(x,f,'g-d')
xlabel('X');
ylabel('Y');
legend('f(x)');
subplot(2,2,4);
plot(x,g,'b:o')
xlabel('X');
ylabel('Y');
legend('g(x)');
Exerciţiul 3:
e=2.71828182846;
[x,y]=meshgrid(0:0.1:pi,-1:0.1:1);
z=(sin(x).^2.*(x-2.*(y).*e.^(abs(-y))));
>> figure(1)
>> plot3(x,y,z)
>> title('plot3');
>> figure(2)
>> mesh(x,y,z)
>> figure(3)
>> surf(x,y,z)
>> title('surf');
>> figure(2)
>> title('mesh');
>> figure(4)
>> meshc(x,y,z)
>> title('meshc');
>> figure(5)
>> surfc(x,y,z)
>> title('surfc');
>> figure(6)
>> contour(x,y,z)
>> title('contour');
>> figure(7)
>> contourf(x,y,z);
>> title('contourf');
>> figure(8)
>> contour3(x,y,z)
>> title('contour3');
contour
1
0.8
0.6
0.4
0.2
-0.2
-0.4
-0.6
-0.8
-1
0 0.5 1 1.5 2 2.5 3
contourf
1
0.8
0.6
0.4
0.2
-0.2
-0.4
-0.6
-0.8
-1
0 0.5 1 1.5 2 2.5 3
Concluzie: