LABORATORIO 3
Nafher Stiven Castañeda
Jhon Albert Figueroa Moreno
Universidad San Buenaventura
PUNTO 1
clc; clear; close all;
% Ocho vectores en el plano (dos por cuadrante, paralelos)
v = [1 4; 2 8; % 1er cuadrante
-5 2; -10 4; % 2do cuadrante
6 -3; -12 -6; % 3er cuadrante
9 1; 27 3]; % 4to cuadrante
colores = ['r','r','b','b','g','g','k','k'];
figure; hold on; grid on; axis equal
for i=1:8
quiver(0,0,v(i,1),v(i,2),0,'Color',colores(i),'LineWidth',2)
end
xlabel('x'); ylabel('y'); title(' Ocho vectores en el plano')
1
PUNTO 2
% Magnitud y ángulo de V1 y V2
V1 = [7 -3];
V2 = [-4 -2];
% Magnitudes
mag1 = norm(V1)
mag1 =
7.6158
mag2 = norm(V2)
mag2 =
4.4721
% Ángulos (en grados)
ang1 = atan2d(V1(2),V1(1))
ang1 =
-23.1986
ang2 = atan2d(V2(2),V2(1))
ang2 =
-153.4349
2
% Mostrar resultados en consola
fprintf('\nResultados punto 2:\n');
Resultados punto 2:
fprintf('|V1| = %.4f, Ángulo 1 = %.2f°\n', mag1, ang1);
|V1| = 7.6158, Ángulo 1 = -23.20°
fprintf('|V2| = %.4f, Ángulo 2 = %.2f°\n', mag2, ang2);
|V2| = 4.4721, Ángulo 2 = -153.43°
% Gráfica de V1 y V2
figure; hold on; grid on; axis equal
quiver(0,0,V1(1),V1(2),0,'r','LineWidth',2,'DisplayName','V1')
quiver(0,0,V2(1),V2(2),0,'b','LineWidth',2,'DisplayName','V2')
xlabel('x'); ylabel('y'); legend
title('Punto 2 Vectores 1 y 2 con sus direcciones')
PUNTO 3
% Vectores en R3
a = [-3 5 5];
b = [7 3 -2];
c = [-6 1 4];
d = [-1 -2 -1];
figure; hold on; grid on; axis equal
3
quiver3(0,0,0,a(1),a(2),a(3),0,'r','LineWidth',2,'DisplayName','a')
quiver3(0,0,0,b(1),b(2),b(3),0,'b','LineWidth',2,'DisplayName','b')
quiver3(0,0,0,c(1),c(2),c(3),0,'g','LineWidth',2,'DisplayName','c')
quiver3(0,0,0,d(1),d(2),d(3),0,'k','LineWidth',2,'DisplayName','d')
xlabel('x'); ylabel('y'); zlabel('z'); legend
title('Punto 3: Vectores en el espacio')
PUNTO 4
% Vectores
a = [-3 5 5];
b = [7 3 -2];
c = [-6 1 4];
d = [-1 -2 -1];
% Producto cruz
axb = cross(a, b);
cxd = cross(c, d);
fprintf('Punto 4:\n');
Punto 4:
fprintf('a × b = [%d %d %d]\n', axb);
a × b = [-25 29 -44]
4
fprintf('c × d = [%d %d %d]\n', cxd);
c × d = [7 -10 13]
PUNTO 5
% Vectores
a = [-3 5 5];
b = [7 3 -2];
c = [-6 1 4];
d = [-1 -2 -1];
% Producto punto
adotb = dot(a, b);
cdotd = dot(c, d);
fprintf('Punto 5:\n');
Punto 5:
fprintf('a · b = %d\n', adotb);
a · b = -16
fprintf('c · d = %d\n', cdotd);
c · d = 0
PUNTO 6
% Vectores
V1 = [7 -3];
V2 = [-4 -2];
% Unitarios
uV1 = V1 / norm(V1);
uV2 = V2 / norm(V2);
fprintf('Punto 6:\n');
Punto 6:
fprintf('uV1 = [%.4f %.4f]\n', uV1);
5
uV1 = [0.9191 -0.3939]
fprintf('uV2 = [%.4f %.4f]\n', uV2);
uV2 = [-0.8944 -0.4472]
% Gráfica
figure; hold on; grid on; axis equal
quiver(0,0,uV1(1),uV1(2),0,'r','LineWidth',2,'DisplayName','uV1')
quiver(0,0,uV2(1),uV2(2),0,'b','LineWidth',2,'DisplayName','uV2')
xlabel('x'); ylabel('y'); legend
title('Punto 6: Vectores unitarios')
PUNTO 7
% Vectores
e = [12 4];
f = [4 4];
suma = e + f;
fprintf('Punto 7:\n');
Punto 7:
fprintf('e + f = [%d %d]\n', suma);
e + f = [16 8]
6
% Gráfica
figure; hold on; grid on; axis equal
quiver(0,0,e(1),e(2),0,'r','LineWidth',2,'DisplayName','e')
quiver(0,0,f(1),f(2),0,'b','LineWidth',2,'DisplayName','f')
quiver(0,0,suma(1),suma(2),0,'k','LineWidth',2,'DisplayName','e+f')
xlabel('x'); ylabel('y'); legend
title('Punto 7: Suma de vectores e y f')