Está en la página 1de 16

UNH

UNIVERSIDAD NACIONAL DE HUANCAVELICA

ESCUELA PROFESIONAL DE INGENIERÍA ELECTRÓNICA -SISTEMAS

EJERCICIOS EN MATLAB

TRABAJO INDIVIDUAL

ASIGNATURA: SOFTWARE APLICADO A ELECTRONICA

CICLO: IV

INGENIERO: HIPOLITO CARBAJAL MORAN

ALUMNO:

 LULO YAURI RICARDO DAMIAN

PAMPAS-2018

PRACTICA N 01: MATRICES


UNH

m1=[1 -7 4;-8 3 6;7 8 3]


m1 =

1 -7 4
-8 3 6
7 8 3

>> m2=[10 -17 40;18 3 5;7 83 34]

m2 =

10 -17 40
18 3 5
7 83 34

>> m3=[2 7;5 -6]

m3 =

2 7
5 -6

>> m4=[10 14 122;-18 3 56;70 -66 88]

m4 =

10 14 122
-18 3 56
70 -66 88

>> m5=[15 -79 0;-81 30 -15 ;76 -13 1]

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 =

0.0464 -0.0630 0.0642


-0.0785 0.0297 0.0452
0.1011 0.0678 0.0630

>> inv(m2)

ans =

-0.0048 0.0594 -0.0031


-0.0088 0.0009 0.0102
0.0225 -0.0145 0.0051

>> inv(m3)

ans =

0.1277 0.1489
0.1064 -0.0426

>> inv(m4)

ans =

0.0168 -0.0393 0.0018


0.0233 -0.0325 -0.0117
0.0041 0.0069 0.0012

>> inv(m5)

ans =

-0.0020 0.0010 0.0146


-0.0130 0.0002 0.0028
-0.0151 -0.0716 -0.0733

>> save('matrices_02')

CALCULOS CON MATRICES


>> cal_01=(m1.*m2)+(m4./m5)

cal_01 =

10.6667 118.8228 Inf


-143.7778 9.1000 26.2667
49.9211 669.0769 190.0000

>> 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')

PRACTICA N 02: NUMEROS COMPLEJOS


>> d01=(4+7i)

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

>> save('numeros complejos')


PRACTICA N 03

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

>> %lo hacemos utilizando la ecuacion cuadratica


>> x1=[-b+sqrt(b^2-4*a*c)]/(2*a)

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

4.0189 4.1189 4.2189 4.3189 4.4189 4.5189

>> 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

>> %DADO EL SISTEMA DE ECUACIONES HALLAR LOS VALORES X1,X2,X3


>> %3X 5X 7X= 40
>> %8X 4X -2X=-12
>> %6X 7X -3X=-41
>> %CONSTRUIR UN FICHERO DE VALORES

3) Construir un fichero valores_02.m


% Textos Superior:
txt_01=uicontrol(gcf,...
'Style','text','String','X1',...
'Position',[40 375 50 22]);
txt_02=uicontrol(gcf,...
'Style','text','String','X2',...
'Position',[100 375 50 22]);
txt_03=uicontrol(gcf,...
'Style','text','String','X3',...
UNH

'Position',[160 375 50 22]);


% Valores X1:
pos_01 = uicontrol(gcf,...
'Style','edit',...
'BackgroundColor','white',...
'FontSize',10,'FontName','Arial',...
'String',[],...
'Position',[40 350 50 22],...
'CallBack','m_01=str2double(get(pos_01,''String''))');
pos_02 = uicontrol(gcf,...
'Style','edit',...
'BackgroundColor','white',...
'FontSize',10,'FontName','Arial',...
'String',[],...
'Position',[40 325 50 22],...
'CallBack','m_02=str2double(get(pos_02,''String''))');
pos_03 = uicontrol(gcf,...
'Style','edit',...
'BackgroundColor','white',...
'FontSize',10,'FontName','Arial',...
'String',[],...
'Position',[40 300 50 22],...
'CallBack','m_03=str2double(get(pos_03,''String''))');
% Valores X2:
pos_04 = uicontrol(gcf,...
'Style','edit',...
'BackgroundColor','white',...
'FontSize',10,'FontName','Arial',...
'String',[],...
'Position',[100 350 50 22],...
'CallBack','m_04=str2double(get(pos_04,''String''))');
pos_05 = uicontrol(gcf,...
'Style','edit',...
'BackgroundColor','white',...
'FontSize',10,'FontName','Arial',...
'String',[],...
'Position',[100 325 50 22],...
'CallBack','m_05=str2double(get(pos_05,''String''))');
pos_06 = uicontrol(gcf,...
'Style','edit',...
'BackgroundColor','white',...
'FontSize',10,'FontName','Arial',...
'String',[],...
'Position',[100 300 50 22],...
'CallBack','m_06=str2double(get(pos_06,''String''))');
% Valores X3:
pos_07 = uicontrol(gcf,...
'Style','edit',...
'BackgroundColor','white',...
'FontSize',10,'FontName','Arial',...
'String',[],...
'Position',[160 350 50 22],...
UNH

'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');

3) Construir un fichero valores_03.m


% Resolución:
m=[m_01 m_04 m_07;m_02 m_05 m_08;m_03 m_06 m_09]
n=[n_01;n_02;n_03]
% Textos:
txt_01=uicontrol(gcf,...
'Style','text','String','X1',...
'Position',[280 350 50 22]);
txt_02=uicontrol(gcf,...
'Style','text','String','X2',...
'Position',[280 325 50 22]);
txt_03=uicontrol(gcf,...
'Style','text','String','X3',...
'Position',[280 300 50 22]);
% Resultados:
res_01 = uicontrol(gcf,...
'Style','text',...
'BackgroundColor','y',...
'FontSize',10,'FontName','Arial',...
'HorizontalAlignment','Left',...
'String',[x(1)],...
'Position',[340 350 120 20]);
res_02 = uicontrol(gcf,...
UNH

'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

% Definir el texto de titulo para este grupo de controles txt_tdir =


uicontrol(gcf,... 'Style','text',...
'BackgroundColor',[ 0.8 0.8 0.8 ],...
'FontSize',10,'FontName','
Arial',...
'HorizontalAlignment','Left'
,... 'String','Tolerancia de
la Resistencia',...
'Position',[350 380 250
20]);

% Definir la propiedad TickDir In con


radiobutton (defecto) td_5 =
uicontrol(gcf,...
'Style','radio',...
UNH

'BackgroundColor',[ 0.8 0.8 0.8 ],...


'FontSize',10,'FontName','Arial',...
'String','+/- 5%',...
'Position',[350 355 75 25],...
'Value',va,...
'CallBack','set(td_5,''Value'',1),set(td_10,''Value'',0),s
et(td_15,''Value'',0),va
=1,vb=0,vc=0,tol=5');

% Definir la propiedad TickDir Out con


radiobutton (defecto) td_10 =
uicontrol(gcf,...
'Style','radio',...
'BackgroundColor',[ 0.8 0.8 0.8 ],...
'FontSize',10,'FontName','Arial',...
'String','+/- 10%',...
'Position',[350 330 75 25],...
'Value',vb,...
'CallBack','set(td_5,''Value'',0),set(td_10,''Value'',1),s
et(td_15,''Value'',0),va
=0,vb=1,vc=0,tol=10');

% Definir la propiedad TickDir Out con


radiobutton (defecto) td_15 =
uicontrol(gcf,...
'Style','radio',...
'BackgroundColor',[ 0.8 0.8 0.8 ],...
'FontSize',10,'FontName','Arial',...
'String','+/- 15%',...
'Position',[350 305 75 25],...
'Value',vb,... 'CallBack','set(td_5,''Value'',0),set(td_10,''Value'',0),set(td_15,''Value'',1),va
=0,vb=0,vc=1,tol=15');

% 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

Construir un fichero cal_02.m

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

También podría gustarte