Documente Academic
Documente Profesional
Documente Cultură
RAPORT
Despre lucrarea de laborator Nr.2
la Mecanică realizată în MATLAB
A efectuat: V.Ciubotaru
A verificat: S.Andronic
Chişinău 2017
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)
graficul functiei f1=2*(x-1)
20 20 -0.4 2.5
0 15 -0.6
ambele pe
2
-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
axele din
-2 -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
dreapta
0
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
ambele pe ambele pe
f1=2*(x-1) f1=2*(x-1)
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
x 10
6
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
>> figure(1)
>> x=[-1:0.05:1];
>> f=asin(x);
>> plot(x,f,'b+:')
>> title('Graficul 1')
>> legend('f(x)=asin(x)')
>> xlabel('Axa x')
>> ylabel('Axa y')
>> clf reset;
>> figure(2)
>> x=[-1:0.05:1];
>> g=acos(x);
>> plot(x,g)
>> plot(x,g,'r>-')
>> title('Graficul 2')
>> legend('g(x)=acos(x)')
>> xlabel('Axa x')
>> ylabel('Axa y')
>>clf reset;
>> figure(3)
>> plot(x,f,'b+:',x,g,'r>-')
>> title('Graficul 3')
>> legend('f(x)=asin(x)','g(x)=acos(x)')
>> xlabel('Axa x')
>> ylabel('Axa y')
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
6
x 10 graficul functiei g=((x-1). 3).*sqrt(x).*(2. x)
3
f(x) şi g(x)
2
-1
-10 -8 -6 -4 -2 0 2 4 6 8 10
>> subplot(3,1,1)
>> plot(x,f,'b+:')
title('Graficul 1')
legend('f(x)=asin(x)')
xlabel('Axa x')
ylabel('Axa y')
>> subplot(3,1,2)
>> plot(x,g,'r>-')
title('Graficul 2')
legend('g(x)=acos(x)')
xlabel('Axa x')
ylabel('Axa y')
>> subplot(3,1,3)
>> plot(x,f,'b+:',x,g,'r>-')
title('Graficul 3')
legend('f(x)=asin(x)','g(x)=acos(x)')
xlabel('Axa x')
ylabel('Axa y')
f(x) g(x) f(x) şi g(x)
Vertical 20
graficul functiei f1=2*(x-1)
-0.4
graficul functiei f2=-(x. (1/3)) 6
graficulx functiei
2.5
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
>> subplot(1,3,1)
>> plot(x,f,'b+:')
title('Graficul 1')
legend('f(x)=asin(x)')
xlabel('Axa x')
ylabel('Axa y')
>> subplot(1,3,2)
>> plot(x,g,'r>-')
title('Graficul 2')
legend('g(x)=acos(x)')
xlabel('Axa x')
ylabel('Axa y')
>> subplot(1,3,3)
>> plot(x,f,'b+:',x,g,'r>-')
title('Graficul 3')
legend('f(x)=asin(x)','g(x)=acos(x)')
xlabel('Axa x')
ylabel('Axa y')
c2) Într-o fereastră – fiecare aparte pe axe diferite şi ambele pe
aceleaşi axe.
f(x)
graficul functiei f2=-(x.( 1/3)) 6
x 10 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
x 10
6 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)
>> subplot(2,2,1)
>> plot(x,f,'b+:')
title('Graficul 1')
legend('f(x)=asin(x)')
xlabel('Axa x')
ylabel('Axa y')
>> subplot(1,2,2)
>> plot(x,f,'b+:',x,g,'r>-')
title('Graficul 3')
legend('f(x)=asin(x)','g(x)=acos(x)')
xlabel('Axa x')
ylabel('Axa y')
>> subplot(2,2,3)
>> plot(x,g,'r>-')
title('Graficul 2')
legend('g(x)=acos(x)')
xlabel('Axa x')
ylabel('Axa y')
f(x) şi g(x)
6
x 10 graficele 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)
>> subplot(2,1,1)
plot(x,f,'b+:',x,g,'r>-')
title('Graficul 3')
legend('f(x)=asin(x)','g(x)=acos(x)')
xlabel('Axa x')
ylabel('Axa y')
>> subplot(2,2,3)
>> plot(x,f,'b+:')
title('Graficul 1')
legend('f(x)=asin(x)')
xlabel('Axa x')
ylabel('Axa y')
>> subplot(2,2,4)
>> plot(x,g,'r>-')
title('Graficul 2')
legend('g(x)=acos(x)')
xlabel('Axa x')
ylabel('Axa y')
Exerciţiul 3:
Metoda Mesh
>> [x,y]=meshgrid(-2:0.1:2*-1:0.1:1);
>> z=(x^2*y^2+2*x*y-3)/(x^2+y^2+1);
>> 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:
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.