Documentos de Académico
Documentos de Profesional
Documentos de Cultura
EJERCICIOS EN MATLAB
TRABAJO INDIVIDUAL
CICLO: IV
ALUMNO:
PAMPAS-2018
1 -7 4
-8 3 6
7 8 3
m2 =
10 -17 40
18 3 5
7 83 34
m3 =
2 7
5 -6
m4 =
10 14 122
-18 3 56
70 -66 88
m5 =
15 -79 0
-81 30 -15
76 -13 1
save ('matrices_01')
MATRIZ TRANSPUESTA
m1.'
ans =
1 -8 7
-7 3 8
4 6 3
>> m2.'
UNH
ans =
10 18 7
-17 3 83
40 5 34
>> m3.'
ans =
2 5
7 -6
>> m4.'
ans =
10 -18 70
14 3 -66
122 56 88
>> m5.'
ans =
15 -81 76
-79 30 -13
0 -15 1
DETERMINANTES
>> det(m1)
ans =
-841
>> det(m2)
ans =
65599
>> det(m3)
ans =
-47
>> det(m4)
ans =
2.3597e+05
>> det(m5)
ans =
8.1186e+04
INVERSA DE UNA MATRIZ
UNH
inv(m1)
ans =
>> inv(m2)
ans =
>> inv(m3)
ans =
0.1277 0.1489
0.1064 -0.0426
>> inv(m4)
ans =
>> inv(m5)
ans =
>> save('matrices_02')
cal_01 =
>> comp_06=isinf((m1.*m2)+(m4./m5))
UNH
comp_06 =
0 0 1
0 0 0
0 0 0
>> comp_07=isnan((m2-3)./(m5-30))
comp_07 =
0 0 0
0 1 0
0 0 0
>> comp_08=any(comp_07)
comp_08 =
0 1 0
>> comp_07=all(m2-3)
comp_07 =
1 0 1
save('matrices_03')
d01 =
4.0000 + 7.0000i
>> d02=(8-2i)
d02 =
8.0000 - 2.0000i
>> d03=(-4+3i)
d03 =
-4.0000 + 3.0000i
>> d04=(-6-2i)
d04 =
-6.0000 - 2.0000i
CALCULAR
>> res01=d01+d02+d03+d04
UNH
res01 =
2.0000 + 6.0000i
>> res02=d02*d03
res02 =
-26.0000 +32.0000i
>> res03=d02/d03
res03 =
-1.5200 - 0.6400i
>> real(res01)
ans =
>> imag(res02)
ans =
32
>> conj(res03)
ans =
-1.5200 + 0.6400i
>> angle(res01+res02)
ans =
2.1341
Resolver una solución cuadrática verificar y graficar con un sencillo archivo *.M
>> %ecuacion cuadratica
>> %ax^2+bx+c=0
>> %Y si a=2,b=4 y c=3
>> a=-2;
>> b=4;
>> c=3;
UNH
x1 =
-0.5811
>> x2=[-b-sqrt(b^2-4*a*c)]/(2*a)
x2 =
2.5811
>> v1=a*x1^2+b*x1+c
v1 =
-4.4409e-16
>> v2=a*x2^2+b*x2+c
v2 =
-1.7764e-15
>> x=[x1-2:0.1:x2+2]
x=
Columns 1 through 11
-2.5811 -2.4811 -2.3811 -2.2811 -2.1811 -2.0811 -1.9811 -1.8811 -1.7811 -1.6811
-1.5811
Columns 12 through 22
-1.4811 -1.3811 -1.2811 -1.1811 -1.0811 -0.9811 -0.8811 -0.7811 -0.6811 -0.5811
-0.4811
Columns 23 through 33
-0.3811 -0.2811 -0.1811 -0.0811 0.0189 0.1189 0.2189 0.3189 0.4189 0.5189
0.6189
Columns 34 through 44
0.7189 0.8189 0.9189 1.0189 1.1189 1.2189 1.3189 1.4189 1.5189 1.6189
1.7189
Columns 45 through 55
UNH
1.8189 1.9189 2.0189 2.1189 2.2189 2.3189 2.4189 2.5189 2.6189 2.7189
2.8189
Columns 56 through 66
2.9189 3.0189 3.1189 3.2189 3.3189 3.4189 3.5189 3.6189 3.7189 3.8189
3.9189
Columns 67 through 72
>> y=a*x.^2+b*x+c;
>> plot(x,y)
>> save('ecuaciones cuadraticas')
PRÁCTICA N 04
Programación. Dado el sistema de ecuaciones hallar los valores X1, X2, X3
'CallBack','m_07=str2double(get(pos_07,''String''))');
pos_08 = uicontrol(gcf,...
'Style','edit',...
'BackgroundColor','white',...
'FontSize',10,'FontName','Arial',...
'String',[],...
'Position',[160 325 50 22],...
'CallBack','m_08=str2double(get(pos_08,''String''))');
pos_09 = uicontrol(gcf,...
'Style','edit',...
'BackgroundColor','white',...
'FontSize',10,'FontName','Arial',...
'String',[],...
'Position',[160 300 50 22],...
'CallBack','m_09=str2double(get(pos_09,''String''))');
% Valores de los terminos Independientes:
npos_01 = uicontrol(gcf,...
'Style','edit',...
'BackgroundColor','white',...
'FontSize',10,'FontName','Arial',...
'String',[],...
'Position',[220 350 50 22],...
'CallBack','n_01=str2double(get(npos_01,''String''))');
npos_02 = uicontrol(gcf,...
'Style','edit',...
'BackgroundColor','white',...
'FontSize',10,'FontName','Arial',...
'String',[],...
'Position',[220 325 50 22],...
'CallBack','n_02=str2double(get(npos_02,''String''))');
npos_03 = uicontrol(gcf,...
'Style','edit',...
'BackgroundColor','white',...
'FontSize',10,'FontName','Arial',...
'String',[],...
'Position',[220 300 50 22],...
'CallBack','n_03=str2double(get(npos_03,''String''))');
% Botón que realiza el calculo:
boton_calculo = uicontrol(gcf,...
'Style','push',...
'FontSize',10,'FontName','Arial',...
'String','Calcular',...
'Position',[50 250 150 22],...
UNH
'CallBack','valores_03');
'Style','text',...
'BackgroundColor','y',...
'FontSize',10,'FontName','Arial',...
'HorizontalAlignment','Left',...
'String',[x(2)],...
'Position',[340 325 120 20]);
res_03 = uicontrol(gcf,...
'Style','text',...
'BackgroundColor','y',...
'FontSize',10,'FontName','Arial',...
'HorizontalAlignment','Left',...
'String',[x(3)],...
'Position',[340 300 120 20]);
PRÁCTICA N 05
Programación. Dado el siguiente circuito eléctrico resolver con la ley de (OHM) si el
sistema Funciona bien, Funciona en el límite o Se Quema.
1Construir un fichero cal_01.m
tol=5 va=1 vb=0 vc=0
% Resistencia
Texto y Valor:
txt_resistencia =
uicontrol(gcf,...
'Style','text',...
'BackgroundColor',[ 0.8 0.8 0.8 ],...
'FontSize',10,'Fo
ntName','Arial',...
'HorizontalAlignm
ent','Center',...
'String','Resisten
cia (ohms)',...
'Position',[40 360
150 30]);
valor_resistencia
= uicontrol(gcf,...
'Style','edit',...
'Backgroundor'
'white',...
'FontSize',14,'Fo
ntName','Arial',...
'String',[],...
'Position',[40 340 150 30],...
'CallBack','r=str2double(get(valor_resistencia,''String''))');
% Potencia
Texto y Valor:
txt_potencia =
uicontrol(gcf,...
UNH
'Style','text',...
'BackgroundColor',[ 0.8 0.8 0.8 ],...
'FontSize',10,'F
ontName','Arial
',...
'HorizontalAlig
nment','Center'
,...
'String','Potenci
a (W)',...
'Position',[40
266 150 30]);
valor_potencia =
uicontrol(gcf,...
'Style','edit',...
'BackgroundColo
r','white',...
'FontSize',14,'Fo
ntName','Arial',...
'String',[],...
'Position',[40 245 150 30],...
'CallBack','p=str2double(get(valor_potencia,''String''))');
% Fuente
Texto y
Valor:
txt_fuente =
uicontrol(gcf,.
..
'Style','text',...
'BackgroundColor',[ 0.8 0.8 0.8 ],...
'FontSize',10,'
FontName','Ari
al',...
'HorizontalAlig
nment','Center'
,...
'String','Fuente
(V)',...
'Position',[40
170 150 30]);
valor_fuente =
uicontrol(gcf,...
'Style','edit',...
'BackgroundColo
r','white',...
'FontSize',14,'Fo
ntName','Arial',...
'String',[],...
'Position',[40 150 150 30],...
'CallBack','f=str2double(get(valor_fuente,''String''))');
% Botón que
realiza el calculo:
boton_calculo =
uicontrol(gcf,...
'Style','push',...
'FontSize',10,'Fo
ntName','Arial',...
'String','Calcular',
...
'Position',[10 10 100 25],...
'CallBack','cal_02');
UNH
p_real=(f^2)/r;
a=p*tol/100;
if p_real<=p-a
s='Funciona bien' col='g'
elseif p-
a<p_real&p_real<p+a s='Funciona en el limite' col='y'
elseif
p_real
>=p+a s='Se Quema' col='r'
end
% Potencia Real Texto y Valor: txt_potencia_real = uicontrol(gcf,... 'Style','text',...
'BackgroundColor',[ 0.8 0.8 0.8 ],...
'FontSize',10,'FontName','Arial',...
'String','Potencia Real (W)',... 'Position',[250 170 300 30]);
valor_fuente = uicontrol(gcf,... 'Style','text',...
'BackgroundColor',[col],...
'FontSize',14,'FontName','Arial',...
'String',[p_real],...
'Position',[250 150 300 30]);
% Estado Texto y Valor: txt_estado = uicontrol(gcf,...
'Style','text',...
'BackgroundColor',[ 0.8 0.8 0.8 ],...
'FontSize',10,'FontName','Arial',... 'String','Estado',...
'Position',[250 100 300 30]);
valor_fuente = uicontrol(gcf,... 'Style','text',...
'BackgroundColor',[col],... 'FontSize',14,'FontName','Arial',... 'String',[s],...
'Position',[250 80 300 30]);
UNH