Académique Documents
Professionnel Documents
Culture Documents
Tarea 1 de Metodos
Tarea 1 de Metodos
EJERCICIOS DE MATLAB
1. EJERCICIO DE FISICA
clc
disp('======================================')
disp('================FISICA I =============')
disp('======================================')
ti=0;
tf=2;
vi=40-(5*ti.^2);
vf=40-(5*tf.^2);
aprom=(vf-vi)/(tf-ti);
fprintf('(A)La aceleracion promedio: % 5.2f m/s^2',aprom),disp(' ')
a=-10*tf;
fprintf('(B)La aceleracion en t=2: %-5.2f m/s^2',a),disp(' ')
disp('======================================')
disp(' tiempo velocidad aceleracion')
for t=0:0.2:2
v=40-(5*t.^2);
a=-10*t;
disp([t v a])
figure (1)
plot(t,v,'b*'),xlabel('tiempo'),ylabel('velocidad'),title('Grafica v-t')
hold on
figure (2)
plot(t,a,'mo'),xlabel('tiempo'),ylabel('aceleracion'),title('Grafica a-t')
hold on
end
disp('======================================')
1 35 -10
2 20 -20
======================================
38 -2
36 -4
34 -6
32 -8
aceleracion
velocidad
30 -10
28 -12
26 -14
24 -16
22 -18
20 -20
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
tiempo tiempo
****************************************************
PROGRAMA PARA ORDENAR 3 NUMEROS EN FORMA ASCENDENTE
****************************************************
ingrese el primer número:15
ingrese el segundo número:0
ingrese el tercer numero:13
0 13 15
3. EJERCICIO DE CINEMATICA
clc
clear all
disp('####################################################')
disp('################## CINEMATICA ######################')
d=0;
for t=0:6
s=1.5*t^3-13.5*t^2+22.5*t;%posicion
v=4.5*t^2-27*t+22.5; % derivada de la posicion
a=9*t-27; %derivada de la velocidad
disp([ t s v a])
figure (1)
plot(t,s,'dr'),ylabel('posicion'),xlabel('tiempo')
hold on
figure(2)
plot(t,v,'ob'),ylabel('velocidad'),xlabel('tiempo')
hold on
figure(3)
plot(t,a,'hk'),ylabel('aceleracion'),xlabel('tiempo')
hold on
d=d+s; %distancia total recorrida
end
disp('distancia total recorrida')
fprintf('la distancia total recorrida: %5.2f ft',d ), disp(' ')
tc=input('ingrese el tiempo final: ');
disp('la posicion final de la particula es :')
sfinal=1.5*tc^3-13.5*tc^2+22.5*t;
disp(sfinal)
10 15
10
0
velocidad
5
posicion
-10
0
-5
-20
-10
-30
-15
-40 -20
0 1 2 3 4 5 6 0 1 2 3 4 5 6
tiempo tiempo
30
20
10
aceleracion
-10
-20
-30
0 1 2 3 4 5 6
tiempo
clc
clear all
disp('****************************************************');
disp(' PROGRAMA PARA HALLAR LOS DIVISORES DE UN NUMERO')
disp('****************************************************');
n=input('ingrese el número :')
c=0;%contador de los divisores
while n<=1;%restricción para el cero y negativos
n=input('ingrese el número:');
end
for g=1:n;
if rem(n,g)==0;%resto d división cero
c=c+1;
disp([g])
end
end
if c==2
'primo'
else
'divisible'
end
Ejecución del programa
****************************************************
PROGRAMA PARA DETERMINAR EL NUMERO DE DIVISORES
****************************************************
clc
clear all
disp('::::::::::::::::::::::::::::::::::::::::::::::: ')
disp(':::::::DETERMINAR LA FUERZA ELECTRICA:::::::::: ')
disp('::::::::::::::::::::::::::::::::::::::::::::::: ')
q1=input(' ingrese valor en (uC)de q1 : ');
q2=input(' ingrese valor en (uC) de q2 : ');
d=-1;
k=9*10^9;
u=10^(-6);
while d<=0;
d=input(' ingrese la variación de la distancia en (m) : ');
end
fprintf('\n\n');
fprintf('%4s\t','');
disp('--------------------------------------------')
fprintf('%10s\t','');
fprintf('distancia%d\t');fprintf('%12s\t');
fprintf('fuerza%d\t');fprintf('\n\n');
fprintf('%4s\t','');
disp('--------------------------------------------')
for D=1:d
f=(k*q1*u*q2*u)/D;
fprintf('%13s\t','');
fprintf('%4.2f\t',D);fprintf('%6s\t','');
fprintf('%4.2f\t',f);fprintf('\n\n');
end
disp('::::::::::::::::::::::::::::::::::::::::::::::::::::: ')
clc
clear all
disp('<><><><><><><><><><><><><><><><><><><><><><><><><><');
disp('<><><><><><><><><>PROCESO ISOBARICO<><><><><><><><>');
disp('<><><><><><><><><><><><><><><><><><><><><><><><><><');
p=input('ingrese el valor de la presion constante en pascales:');
while p<=0
'LA PRESION NO PUEDE SER NEGATIVA'
p=input('ingrese el valor de la presion en pascales:');
end
v1=input('ingrese el valor del volumen1 en metros cubicos:');
while v1<0
'EL VOLUMEN NO PUEDE SER NEGATIVO'
v1=input('ingrese el valor del volumen1 en metros cubicos:');
end
t=input('ingrese el valor de la temperatura en kelvin:');
Q=input('ingrese el valor del calor en joules: ');
for t2=0:50:t
v2=(v1*t2)/t;
W=p*(v2-v1);
U=Q-W;
disp([v2,W,U]);
plot(v2,t2,'go'),title('volumen/temperatura'),xlabel('temperatura'),ylabel('volumen'),
grid on,hold on;
end
clc
clear all
disp('O-O-O-O-O-O-O-O-O-O-O-O-O-O-O-O-O-O-O-O-O-O-O-O-O-O-O')
disp('O-O-O-O-O-O----OBTENCION DE LA DERIVADA----O-O-O-O-O-O')
disp('O-O-O-O-O-O-O-O-O-O-O-O-O-O-O-O-O-O-O-O-O-O-O-O-O-O-O')
clc;
disp('//////////////////////////////////////////////////////////////////')
disp('/////PROGRAMA PARA HALLAR LA INTEGRAL DE sec(x)^2 /////')
disp('//////////////////////////////////////////////////////////////////')
a=input('ingrese el limite superior:');
b=input('ingrese el limite inferior:');
if a>b;
r=tan(a)-tan(b);
disp('el resultado de la integral es:')
disp(r)
else
r=tan(b)-tan(a);
disp('el resultado de la integral es:')
disp(r)
end
disp('//////////////////////////////////////////////////////////////////')
clc,clear all
x=input('Ingrese el punto x=')
y=input('ingrese el punto y=')
if x>0 & y>0
R=('Pertenece al cuadrante I')
else if x<0 & y>0
R=('Pertenece al cuadrante II')
else if x<0 & y<0
R=('Pertenece al cuadrante III')
else
R=('Pertenece al cuadrante IV')
end
end
end
Ejecución del programa