Created
March 2, 2022 12:34
-
-
Save RenatoPilatti/80ba3083cd2640fd1bd57dff00512fc0 to your computer and use it in GitHub Desktop.
Suma De n Vectores en R2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% | |
clc | |
clear | |
disp("Programa para sumar vectores en R2") | |
disp("Autor: Renato Pilatti 01/03/2022") | |
disp(" "); | |
disp(" "); | |
%% ----------------------- | |
%% INGRESO DE DATOS: | |
%% ----------------------- | |
disp("---------------------------"); | |
disp(" D A T O S "); | |
disp("---------------------------"); | |
disp(""); | |
%% n | F magnitud | angulo respecto a x | | |
disp("Fuerzas:"); | |
disp(" n | magnitud | angulo [°]"); | |
F = [1 50 30; | |
2 100 280; | |
3 0 0; | |
4 0 0; | |
5 0 0; | |
6 0 0; | |
7 0 0; | |
;] | |
disp("Número de vectores:"); | |
%% n = número de Vectores. | |
n = F(end,1) | |
%% ----------------------- | |
%% FIN DE INGRESO DE DATOS | |
%% ----------------------- | |
%% No modificar a partir de aquí | |
%% Matriz para descomponer las fuerzas. | |
a = zeros(n,3); | |
for i = 1:n | |
a(i,1)=F(i,1); | |
a(i,2)=F(i,2)*cosd(F(i,3)); | |
a(i,3)=F(i,2)*sind(F(i,3)); | |
endfor | |
disp("Fuerzas descompuestas:"); | |
disp(" n | Fx | Fy"); | |
a | |
%% Calculando las componentes de la resultante. | |
Rx=sum(a(:,2)); | |
Ry = sum(a(:,3)); | |
disp(""); | |
disp(""); | |
disp("---------------------------"); | |
disp(" R E S U L T A D O S"); | |
disp("---------------------------"); | |
disp("Magnitud de la Resultante:"); | |
R = sqrt(Rx^2+Ry^2) | |
%% Condicional para encontrar el correcto alfa. | |
if (Ry>0 && Rx>0); | |
alfa = rad2deg(atan(Ry/Rx)) | |
endif | |
if (Rx<0 && Ry>0); | |
alfa = 90-(rad2deg(atan(Rx/Ry))) | |
endif | |
if (Ry<0 && Rx<0); | |
alfa = 180+(rad2deg(atan(Ry/Rx))) | |
endif | |
if (Ry<0 && Rx>0); | |
alfa = 360+(rad2deg(atan(Ry/Rx))) | |
endif | |
disp(""); | |
disp("Componentes de la Resultante:"); | |
r=zeros(1,2); | |
disp(" x y"); | |
r(1,1)=Rx; | |
r(1,2)=Ry; | |
r |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment