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
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
g(x)
0
-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
6 3 x
x 10 graficul functiei g=((x-1). ).*sqrt(x).*(2. )
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)) 6 6
x 10 graficele functiei 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*3.14:0.05:3*3.14];
>> f=sin(x);
>> plot(x);
>> legend('f');
>> clf reset;
>> x=[-2*3.14:0.05:3*3.14];
>> g=(sin(x).^2);
>> plot(x,g;)
>> legend('g')
b) Prezentarea graficelor într-o fereastră pe aceleaşi axe:
>> x=[-2*3.14:0.05:3*3.14];
>> f=sin(x);
>> g=(sin(x).^2);
>> figure(1);
>> plot(x,f);
>> plot(x,g);
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
figure(1);
x=[-2*3.14:0.05:3*3.14];
f=sin(x);
g=(sin(x).^2);
subplot(3,1,1);
plot(x,f);
hold on
xlabel('axa x');
ylabel('axa y');
legend('functia 1');
subplot(3,1,2);
plot(x,g);
xlabel('axa x');
ylabel('axa y');
legend('Functia 2');
subplot(3,1,3);
hold on
plot(x,f);
plot(x,g);
xlabel('axa x');
ylabel('axa y');
Vertical 20
graficul functiei f1=2*(x-1)
-0.4
graficul functiei f2=-(x.(1/3)) graficul
2.5
6
functiei
x 10 g=((x-1).3).*sqrt(x).*(2.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
x=[-2*3.14:0.05:3*3.14];
f=sin(x);
g=(sin(x).^2);
subplot(1,3,1);
plot(x,f)
xlabel('axa x');
ylabel('axa y');
legend('Functia 1');
subplot(1,3,2);
plot(x,g);
xlabel('axa x');
ylabel('axa y');
legend('functia 2');
subplot(1,3,3);
plot(x,f,x,g);
xlabel('axa x');
ylabel('axa y');
-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
g(x)
figure(3)
x=[-2*3.14:0.05:3*3.14];
f=sin(x);
g=(sin(x).^2);
subplot(2,2,1);
plot(x,f);
xlabel('axa x');
ylabel('axa y');
legend('Functia 1');
subplot(2,2,3);
plot(x,g);
xlabel('axa x');
ylabel('axa y');
legend('Functia 2');
subplot(1,2,2);
plot(x,f,x,g);
xlabel('axa x');
ylabel('axa y');
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(3)
x=[-2*3.14:0.05:3*3.14];
f=sin(x);
g=(sin(x).^2);
subplot(2,2,3);
plot(x,f);
xlabel('axa x');
ylabel('axa y');
legenda('Functia 1');
subplot(2,2,4);
plot(x,g);
xlabel('axa x');
ylabel('axa y');
legend('Functia 2');
subplot(2,1,1);
plot(x,f,x,g);
xlabel('axa x');
ylabel('axa y');
Metoda Mesh
>> [x,y]=meshgrid(-pi./2:0.1:3.*pi./2,-pi:0.1:pi);
>> z=2.*sin(x+2*x*y).*cos(3*x*y);
>> figure(1);
>> mesh(x,y,z);
>> title('Mesh');
Metoda Surf
>> figure(2);
>> surf(x,y,z);
>> title('Surf');
Metod 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:
Efectuând lucrarea de laborator nr.2 am făcut cunostinţă cu comenzile de bază
pentru construirea graficelor în sistemul MATLAB. Tipul graficului depinde de
structura funcţiei şi de intervalele care ne sunt date. Pachetul MATLAB are diferite
tipuri de grafice. Am construit grafice atât bidimensionale cât şi tridimensionale
folosind diferite comenzi: plot, subplot, meshgrid, contourf, contour3 şi altele.
Sistemul MATLAB este usor de folosit şi în acelaşi timp ne oferă o gamă largă de
posibilităţi de construire a graficelor şi de aceea el poate fi folosit în diferite
domenii.