Está en la página 1de 52

Escuela Politécnica Nacional

Calidad de Energía Eléctrica

Trabajo Grupal 6

Nombres: Fecha: 15/09/2021


Andres Santamaria
Carlos Taipe
Francisco Valencia Lomas
Sebastian Valencia Pérez
Darwin Yanez
Andres Zapata

Tema: Verificar la correcta modelación de ALIMENTADORES DE DISTRIBUCIÓN, para


flujos de armónicos. Modele una fuente de corriente que inyecte armónicos de baja, media y
alta frecuencia. Y conecte un alimentador de distribución con el modelo para estudios de
armónicos, verificar los resultados en relación a los flujos de armónicos con cada modelo
para diferentes órdenes de armónicos.

INTRODUCCIÓN

El incremento en el uso cada vez más frecuente de cargas no lineales en usuarios


residenciales, ha provocado en los últimos años una mayor dedicación entre los
investigadores de la ingeniería eléctrica al problema de la distorsión de la onda de tensión
en los sistemas de distribución. Las expresiones “calidad de potencia”, “calidad de energía
eléctrica” o PQ se asocian a la forma de onda en las líneas residenciales, comerciales e
industriales. Los armónicos se producen debido a cargas no lineales conectadas a la red,
las cuales absorben corriente de forma no sinusoidal. La calidad de la energía se ve
afectada en parte por la creación de aparatos eléctricos los cuales contienen dispositivos
electrónicos, es decir, cargas no lineales como diodos tiristores, SCR’s, etc., este tipo de
cargas realizan conmutaciones en su operación en un intervalo de tiempo, lo cual ocasiona
una deformación de la señal fundamental.

Armónicos en sistemas eléctricos

En la actualidad debido a los diferentes equipos utilizados y al incremento de la demanda


existe una gran presencia de armónicos en el sistema eléctrico. Los armónicos en los SEP
se clasifican debido a tres parámetros que definen 4 correctamente la función del armónico
existente en las redes eléctricas . Estos parámetros se muestran en la Tabla 1 y se definen
a continuación:

• Orden: el orden indica cuántas veces es mayor la frecuencia del armónico en base a la
fundamental.
• Frecuencia: se obtiene multiplicando la frecuencia fundamental del sistema por el orden
del armónico (Mantilla, 2020) .

▪ Secuencia: se refiere al giro del armónico con respecto a la fundamental; si la rotación es


discreta es secuencia positiva (+), si la rotación es inversa es secuencia negativa (-) y si no
tiene sentido de rotación es secuencia cero (0) (Mantilla, 2020).

Tabla 1. Parametros de Armonicos (Mantilla, 2020)

Los armónicos de orden par solo aparecen cuando hay asimetría en la señal mientras que
los armónicos de orden impar se encuentran en las redes eléctricas. Para regular la
inyección de corrientes armónicos y limitar los niveles de distorsión armónica total
proporcionada por las empresas de distribución, existen una serie de normas
Internacionales (Mantilla, 2020).
MODELOS DE LA RED

Los elementos del sistema de potencia para simulación de armónicos deben ser adecuados
para representar las características y respuestas que cada uno de estos tiene ante la
circulación de corrientes armónicas por la red.Los elementos del sistema de potencia para
simulación de armónicos deben ser adecuados para representar las características y
respuestas que cada uno de estos tiene ante la circulación de corrientes armónicas por la
red (Barrera, 2020).

Línea larga de transmisión

Se realizó el análisis de armónicos para líneas de transmisión bajo el modelo 𝜋𝜋 de


parámetros distribuidos, que se puede apreciar el cálculo para la señal fundamental así
como para los armónicos en la línea de transmisión larga, teniendo en cuenta que las líneas
de transmisión largas son aquellas cuya longitud sobrepasa los 250 km, basado en la
impedancia , admitancia y longitud de la línea que puede ser de forma incremental para
una mejor representación de la misma, se ilustra en la fig. 1 (AYALA, 2017).

Alimentadores

Líneas y cables Las líneas de transmisión y los cables, tanto aéreos como subterráneos, se
modelan mediante el equivalente PI de la Fig. 1 considerando parámetros distribuidos para
todas las frecuencias de estudio (Barrera, 2020).

Fig. 1. Modelos pi de la línea de transmisión larga (Parámetros distribución) (Barrera, 2020)


FUENTES DE DISTORSIÓN

La principal forma de modelar la introducción de efectos que alteran la forma de onda de


voltaje o corriente en los sistemas eléctricos son las fuentes de corriente, donde para un
determinado armónico le corresponde un porcentaje de corriente fundamental. Las fuentes
de voltaje armónicas pueden ser también empleadas, pero no son un medio común de
modelación. La Tabla 2. presenta los tres modelos más empleados por programas
computacionales (Barrera, 2020).

Tabla 2. Modelos de fuentes de distorsión armónicos (Barrera, 2020)

SIMULACIÓN

Para la implementación de los modelos, se utilizó el software de simulación MatLab,

mediante la interfaz gráfica de GUIDE. Modelando de esta manera el efecto que tienen los

armónicos en los alimentadores, tanto para bajas, medias y altas frecuencias.


La simulación se realizó tomando valores reales de líneas de distribución.

La interfaz consta de datos ingresados por el usuario como son: Parámetros del

Alimentador, parámetros de los armónicos. Y las gráficas resultantes del análisis de los

armónicos previamente propuestos en el alimentador.

Interfaz Gráfica GUIDE

RESULTADOS

Para las corrientes armónicas, el valor de amplitud del armónico es inversamente


proporcional al número de armónicos. Por lo que se han comparado con dicha lógica 3
armónicos y con 3 valores de amplitud diferentes para poder observar de manera eficaz la
contribución de dichas formas de onda a la onda final.

Los casos fueron:

● Bajo armónico: el 5to armónico con una amplitud del 50%


● medio armónico: el 17vo armónico con una amplitud del 30%
● Alto armónico: el 49vo armónico con una amplitud del 5%
Simulación para 5to Armónico, 50% de Amplitud

Simulación Armónico N°17, 30% de amplitud


Simulación Armónico N°49, Amplitud 5%

Del mismo modo para poder observar de manera eficaz las perturbaciones y lo que
sucedería de si todos los armónicos llegasen a tener los mismos valores de amplitud y que
esta sea representativa, se usó los mismos armónicos pero con una amplitud del 60%

Armónico N°49, Amplitud 60%


Armónico N°17, Amplitud 60%

Armónico N°5, Amplitud 60%


CONCLUSIONES

Gracias a la simulación se puede observar que cuando se toma el razonamiento de que la

amplitud y el número de armónico son inversamente proporcionales, las formas de onda a

un mayor armónico y menor amplitud la forma de onda final es semejante a la forma de

onda de la fundamental, mientras que al tener un armónico de bajo valor y alta amplitud, la

distorsión es considerable.

Al considerar valor de amplitud de 60% se puede observar que todos los armónicos

distorsionan en gran medida la forma de onda de la fundamental, pero a mayor número de

armónicos tiende a seguir la forma de onda sin distorsión.

Con la ayuda del software MATLAB se logró efectuar de manera eficiente el estudio de

distorsión de corriente armónica para una línea de distribución de energía eléctrica con 30

km de distancia, de esta manera se pudo visualizar la afectación a las ondas de corriente

cuando se insertan distintos números de armónicos a la red eléctrica, considerando que a

mayor número de armónicos la amplitud del armónico es menor y viceversa.

Las redes eléctricas de distribución de energía se ven afectadas por la distorsión armónica

debido a las cargas no lineales que se presentan en la mayoría de las cargas constituidas

por equipos electrónicos, dichas corrientes armónicas que se inyectan en la red pueden

provocar que los equipos de protección operen de forma ineficiente y además que existan

pérdidas excesivas en la red de Distribución.


References

AYALA, C. M. (2017, Julio). MODELACIÓN DE LA PROPAGACIÓN DE ARMÓNICOS EN

SISTEMAS DE TRANSMISIÓN ELÉCTRICA.

https://dspace.ups.edu.ec/bitstream/123456789/14348/4/UPS-KT01385.pdf

Barrera, C. A. (2020). Métodos de simulación de armónicos en sistemas eléctricos de

potencia. http://www.scielo.org.co/pdf/itec/v17n2/1692-1798-itec-17-02-73.pdf

Mantilla, N. I. (2020, Octubre). Simulación de Flujos de Potencia con presencia de contenido

Armónico usando el Método Frecuencial.

https://dspace.ups.edu.ec/bitstream/123456789/19332/1/UPS%20-%20TTS184.pdf

ANEXOS

Código de implementación

Análisis de armónicos

function varargout = Analisis_armonicos(varargin)


% ANALISIS_ARMONICOS MATLAB code for Analisis_armonicos.fig
% ANALISIS_ARMONICOS, by itself, creates a new ANALISIS_ARMONICOS or raises the existing
% singleton*.
%
% H = ANALISIS_ARMONICOS returns the handle to a new ANALISIS_ARMONICOS or the handle to
% the existing singleton*.
%
% ANALISIS_ARMONICOS('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in ANALISIS_ARMONICOS.M with the given input arguments.
%
% ANALISIS_ARMONICOS('Property','Value',...) creates a new ANALISIS_ARMONICOS or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Analisis_armonicos_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Analisis_armonicos_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help Analisis_armonicos

% Last Modified by GUIDE v2.5 15-Sep-2021 22:41:54

% Begin initialization code - DO NOT EDIT


gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Analisis_armonicos_OpeningFcn, ...
'gui_OutputFcn', @Analisis_armonicos_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT

% --- Executes just before Analisis_armonicos is made visible.


function Analisis_armonicos_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to Analisis_armonicos (see VARARGIN)

% Choose default command line output for Analisis_armonicos


handles.output = hObject;

% Update handles structure


guidata(hObject, handles);

% UIWAIT makes Analisis_armonicos wait for user response (see UIRESUME)


% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = Analisis_armonicos_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure


varargout{1} = handles.output;

% --- Executes on button press in radiobutton1.


function radiobutton1_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.radiobutton1,'value',1);
set(handles.radiobutton2,'value',0);
set(handles.radiobutton3,'value',0);
set(handles.radiobutton4,'value',0);
set(handles.radiobutton5,'value',0);

set(handles.edit1,'enable','on');
set(handles.edit6,'enable','on');
set(handles.edit11,'enable','on');

set(handles.edit2,'enable','off');
set(handles.edit7,'enable','off');
set(handles.edit12,'enable','off');

set(handles.edit3,'enable','off');
set(handles.edit8,'enable','off');
set(handles.edit13,'enable','off');

set(handles.edit4,'enable','off');
set(handles.edit9,'enable','off');
set(handles.edit14,'enable','off');

set(handles.edit5,'enable','off');
set(handles.edit10,'enable','off');
set(handles.edit15,'enable','off');

% Hint: get(hObject,'Value') returns toggle state of radiobutton1

% --- Executes on button press in radiobutton2.


function radiobutton2_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.radiobutton1,'value',0);
set(handles.radiobutton2,'value',1);
set(handles.radiobutton3,'value',0);
set(handles.radiobutton4,'value',0);
set(handles.radiobutton5,'value',0);

set(handles.edit1,'enable','on');
set(handles.edit6,'enable','on');
set(handles.edit11,'enable','on');

set(handles.edit2,'enable','on');
set(handles.edit7,'enable','on');
set(handles.edit12,'enable','on');

set(handles.edit3,'enable','off');
set(handles.edit8,'enable','off');
set(handles.edit13,'enable','off');

set(handles.edit4,'enable','off');
set(handles.edit9,'enable','off');
set(handles.edit14,'enable','off');

set(handles.edit5,'enable','off');
set(handles.edit10,'enable','off');
set(handles.edit15,'enable','off');
% Hint: get(hObject,'Value') returns toggle state of radiobutton2

% --- Executes on button press in radiobutton3.


function radiobutton3_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.radiobutton1,'value',0);
set(handles.radiobutton2,'value',0);
set(handles.radiobutton3,'value',1);
set(handles.radiobutton4,'value',0);
set(handles.radiobutton5,'value',0);

set(handles.edit1,'enable','on');
set(handles.edit6,'enable','on');
set(handles.edit11,'enable','on');

set(handles.edit2,'enable','on');
set(handles.edit7,'enable','on');
set(handles.edit12,'enable','on');

set(handles.edit3,'enable','on');
set(handles.edit8,'enable','on');
set(handles.edit13,'enable','on');

set(handles.edit4,'enable','off');
set(handles.edit9,'enable','off');
set(handles.edit14,'enable','off');

set(handles.edit5,'enable','off');
set(handles.edit10,'enable','off');
set(handles.edit15,'enable','off');
% Hint: get(hObject,'Value') returns toggle state of radiobutton3

% --- Executes on button press in radiobutton4.


function radiobutton4_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.radiobutton1,'value',0);
set(handles.radiobutton2,'value',0);
set(handles.radiobutton3,'value',0);
set(handles.radiobutton4,'value',1);
set(handles.radiobutton5,'value',0);

set(handles.edit1,'enable','on');
set(handles.edit6,'enable','on');
set(handles.edit11,'enable','on');

set(handles.edit2,'enable','on');
set(handles.edit7,'enable','on');
set(handles.edit12,'enable','on');

set(handles.edit3,'enable','on');
set(handles.edit8,'enable','on');
set(handles.edit13,'enable','on');
set(handles.edit4,'enable','on');
set(handles.edit9,'enable','on');
set(handles.edit14,'enable','on');

set(handles.edit5,'enable','off');
set(handles.edit10,'enable','off');
set(handles.edit15,'enable','off');
% Hint: get(hObject,'Value') returns toggle state of radiobutton4

% --- Executes on button press in radiobutton5.


function radiobutton5_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.radiobutton1,'value',0);
set(handles.radiobutton2,'value',0);
set(handles.radiobutton3,'value',0);
set(handles.radiobutton4,'value',0);
set(handles.radiobutton5,'value',1)

set(handles.edit1,'enable','on');
set(handles.edit6,'enable','on');
set(handles.edit11,'enable','on');

set(handles.edit2,'enable','on');
set(handles.edit7,'enable','on');
set(handles.edit12,'enable','on');

set(handles.edit3,'enable','on');
set(handles.edit8,'enable','on');
set(handles.edit13,'enable','on');

set(handles.edit4,'enable','on');
set(handles.edit9,'enable','on');
set(handles.edit14,'enable','on');

set(handles.edit5,'enable','on');
set(handles.edit10,'enable','on');
set(handles.edit15,'enable','on');
% Hint: get(hObject,'Value') returns toggle state of radiobutton5

function edit1_Callback(hObject, eventdata, handles)


% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit1 as text


% str2double(get(hObject,'String')) returns contents of edit1 as a double

% --- Executes during object creation, after setting all properties.


function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit2_Callback(hObject, eventdata, handles)


% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit2 as text


% str2double(get(hObject,'String')) returns contents of edit2 as a double

% --- Executes during object creation, after setting all properties.


function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit3_Callback(hObject, eventdata, handles)


% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit3 as text


% str2double(get(hObject,'String')) returns contents of edit3 as a double

% --- Executes during object creation, after setting all properties.


function edit3_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit4_Callback(hObject, eventdata, handles)


% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit4 as text
% str2double(get(hObject,'String')) returns contents of edit4 as a double

% --- Executes during object creation, after setting all properties.


function edit4_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit5_Callback(hObject, eventdata, handles)


% hObject handle to edit5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit5 as text


% str2double(get(hObject,'String')) returns contents of edit5 as a double

% --- Executes during object creation, after setting all properties.


function edit5_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit6_Callback(hObject, eventdata, handles)


% hObject handle to edit6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit6 as text


% str2double(get(hObject,'String')) returns contents of edit6 as a double

% --- Executes during object creation, after setting all properties.


function edit6_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit7_Callback(hObject, eventdata, handles)


% hObject handle to edit7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit7 as text


% str2double(get(hObject,'String')) returns contents of edit7 as a double

% --- Executes during object creation, after setting all properties.


function edit7_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit8_Callback(hObject, eventdata, handles)


% hObject handle to edit8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit8 as text


% str2double(get(hObject,'String')) returns contents of edit8 as a double

% --- Executes during object creation, after setting all properties.


function edit8_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit9_Callback(hObject, eventdata, handles)


% hObject handle to edit9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit9 as text


% str2double(get(hObject,'String')) returns contents of edit9 as a double

% --- Executes during object creation, after setting all properties.


function edit9_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit10_Callback(hObject, eventdata, handles)


% hObject handle to edit10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit10 as text


% str2double(get(hObject,'String')) returns contents of edit10 as a double

% --- Executes during object creation, after setting all properties.


function edit10_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit11_Callback(hObject, eventdata, handles)


% hObject handle to edit11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit11 as text


% str2double(get(hObject,'String')) returns contents of edit11 as a double

% --- Executes during object creation, after setting all properties.


function edit11_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit12_Callback(hObject, eventdata, handles)


% hObject handle to edit12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit12 as text


% str2double(get(hObject,'String')) returns contents of edit12 as a double

% --- Executes during object creation, after setting all properties.


function edit12_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit13_Callback(hObject, eventdata, handles)


% hObject handle to edit13 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit13 as text


% str2double(get(hObject,'String')) returns contents of edit13 as a double

% --- Executes during object creation, after setting all properties.


function edit13_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit13 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit14_Callback(hObject, eventdata, handles)


% hObject handle to edit14 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit14 as text


% str2double(get(hObject,'String')) returns contents of edit14 as a double
% --- Executes during object creation, after setting all properties.
function edit14_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit14 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit15_Callback(hObject, eventdata, handles)


% hObject handle to edit15 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit15 as text


% str2double(get(hObject,'String')) returns contents of edit15 as a double

% --- Executes during object creation, after setting all properties.


function edit15_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit15 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

% --- Executes on button press in pushbutton1.


function pushbutton1_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton1 (see GCBO)


% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%Inicialización de valores
%% Fuente de corriente
global Amp o_h Pflujo_h Qflujo_h Ires I_h phi_h Pflujo_harmonic Qflujo_harmonic;
Pflujo_harmonic=0;
Qflujo_harmonic=0;
Vbase=230; %[kV]
Sbase=100; %[MVA]
f_fn=60; %frecuencia natural
Vr=1; % voltaje en PCC
Ve=1.11;
phi_e=27.76*pi/180; %grados
fp_carga=0.92; %inductivo
phi_r=acos(fp_carga); % ángulo phi
w_fn=2*pi*f_fn; % velocidad angular
t=0:1/(100*f_fn):0.05; %vector de tiempo
Zbase=Vbase.^2/Sbase;
Ibase=Vbase*1000/Zbase;
i_carga=sin(w_fn.*t+phi_r)*Ibase; %corriente de carga sin distorción armónica
Irms_carga=abs(sin(w_fn.*pi/2)*Ibase)/sqrt(2); %valor rms a 60 Hz
% Parámetros para L/T
R=str2double(get(handles.edit16,'String'));%resistencia
L=(str2double(get(handles.edit18,'String')))/1e3;%Inductancia
C=(str2double(get(handles.edit19,'String')))/1e6;%Capacitancia
long_LT=str2double(get(handles.edit20,'String'));%Longitud L/T
%Resistencia
R_fn=R*long_LT;
R_pu=R_fn/Zbase;
%Inductancia
X=w_fn*L*long_LT;
X_pu=X/Zbase;
%Capacitancia
Y=w_fn*C*long_LT;
Y_pu=Y/Zbase;
G=R_pu;
B=X_pu;
%Flujos Base
Pflujo=Ve*((Ve-Vr*cos(phi_e-phi_r))*G+Vr*sin(phi_e-phi_r)*B);
set(handles.edit22,'string',Pflujo);
Qflujo=Ve*((Ve-Vr*cos(phi_e-phi_r))*B-Vr*sin(phi_e-phi_r)*G-Ve*Y_pu/2);
set(handles.edit26,'string',Qflujo);
%% Fuente de corriente (5 armonicos)
aux1=get(handles.radiobutton1,'value');
aux2=get(handles.radiobutton2,'value');
aux3=get(handles.radiobutton3,'value');
aux4=get(handles.radiobutton4,'value');
aux5=get(handles.radiobutton5,'value');
if aux1==1
n_h=1;
o_h=1:n_h; Amp=1:n_h; phi_h=1:n_h;
o_h(1)=str2double(get(handles.edit1,'String'));
Amp(1)=str2double(get(handles.edit6,'String'));
phi_h(1)=str2double(get(handles.edit11,'String'));

end
if aux2==1
n_h=2;
o_h=1:n_h; Amp=1:n_h; phi_h=1:n_h;

o_h(1)=str2double(get(handles.edit1,'String'));
Amp(1)=str2double(get(handles.edit6,'String'));
phi_h(1)=str2double(get(handles.edit11,'String'));

o_h(2)=str2double(get(handles.edit2,'String'));
Amp(2)=str2double(get(handles.edit7,'String'));
phi_h(2)=str2double(get(handles.edit12,'String'));

end
if aux3==1
n_h=3;
o_h=1:n_h; Amp=1:n_h; phi_h=1:n_h;

o_h(1)=str2double(get(handles.edit1,'String'));
Amp(1)=str2double(get(handles.edit6,'String'));
phi_h(1)=str2double(get(handles.edit11,'String'));

o_h(2)=str2double(get(handles.edit2,'String'));
Amp(2)=str2double(get(handles.edit7,'String'));
phi_h(2)=str2double(get(handles.edit12,'String'));

o_h(3)=str2double(get(handles.edit3,'String'));
Amp(3)=str2double(get(handles.edit8,'String'));
phi_h(3)=str2double(get(handles.edit13,'String'));
end
if aux4==1
n_h=4;
o_h=1:n_h; Amp=1:n_h; phi_h=1:n_h;

o_h(1)=str2double(get(handles.edit1,'String'));
Amp(1)=str2double(get(handles.edit6,'String'));
phi_h(1)=str2double(get(handles.edit11,'String'));

o_h(2)=str2double(get(handles.edit2,'String'));
Amp(2)=str2double(get(handles.edit7,'String'));
phi_h(2)=str2double(get(handles.edit12,'String'));

o_h(3)=str2double(get(handles.edit3,'String'));
Amp(3)=str2double(get(handles.edit8,'String'));
phi_h(3)=str2double(get(handles.edit13,'String'));

o_h(4)=str2double(get(handles.edit4,'String'));
Amp(4)=str2double(get(handles.edit9,'String'));
phi_h(4)=str2double(get(handles.edit14,'String'));
end
if aux5==1
n_h=5;
o_h=1:n_h; Amp=1:n_h; phi_h=1:n_h;

o_h(1)=str2double(get(handles.edit1,'String'));
Amp(1)=str2double(get(handles.edit6,'String'));
phi_h(1)=str2double(get(handles.edit11,'String'));

o_h(2)=str2double(get(handles.edit2,'String'));
Amp(2)=str2double(get(handles.edit7,'String'));
phi_h(2)=str2double(get(handles.edit12,'String'));

o_h(3)=str2double(get(handles.edit3,'String'));
Amp(3)=str2double(get(handles.edit8,'String'));
phi_h(3)=str2double(get(handles.edit13,'String'));

o_h(4)=str2double(get(handles.edit4,'String'));
Amp(4)=str2double(get(handles.edit9,'String'));
phi_h(4)=str2double(get(handles.edit14,'String'));

o_h(5)=str2double(get(handles.edit5,'String'));
Amp(5)=str2double(get(handles.edit10,'String'));
phi_h(5)=str2double(get(handles.edit15,'String'));
end
%% Más código
Amp_Ih=Amp*Irms_carga/100;
f_h=f_fn.*o_h; %frecuencia del armonico
phi_h=phi_h*pi/180;
for i=1:n_h
for j=1:length(t)
I_h(i,j)=Amp_Ih(i)*sin(o_h(i)*w_fn.*t(j)+phi_h(i));
end
end
aux=sum(I_h);
Ires=aux+i_carga;
%% Parámetros Distribuidos
% Constantes
BR=0.8; AR=0.1; AL=1; BL=-0.07;
% Dependencia de R
R_h=R.*(1+AR.*(f_fn./f_h-1)).^BR;
R_ht=R_h.*long_LT;
R_pu_h=R_ht./Zbase;
% Dependencia de L
L_h=L.*AL.*(f_fn./f_h).^BL;
X_ht=w_fn.*o_h.*L.*long_LT;
X_pu_h=X_ht./Zbase;
% Dependencia de G
G_h=(1/G.*(1+AR.*(f_fn./f_h-1)).^BR).^-1; %pu
% Dependencia de C
Y_h=o_h.*Y_pu; %pu
% Rama paralela de G y C
GY=G_h+Y_h; %pu
G_d=R_pu_h;
B_d=X_pu_h;
%Flujos Armónicos
for i=1:n_h
Pflujo_h(i)=Ve*((Ve-Vr*cos(phi_e-phi_r))*G_d(i)+Vr*sin(phi_e-phi_r)*B_d(i));
Qflujo_h(i)=Ve*((Ve-Vr*cos(phi_e-phi_r))*B_d(i)-Vr*sin(phi_e-phi_r)*G_d(i)-Ve*GY(i)/2);

end
Pflujo_f=sum(Pflujo_h);
set(handles.edit23,'string',Pflujo_f);
Qflujo_f=sum(Qflujo_h);
set(handles.edit27,'string',Qflujo_f);

%% Teoria de Ondas

for i=1:n_h
Rac_pu(i)=R_pu*((1+0.646*o_h(i)^2)/(192+0.518*o_h(i)^2));
Rf_pu(i)=Rac_pu(i)*(1+AR*((1/o_h(i))-1))^BR;
XLf(i)=2*pi*f_fn*o_h(i)*L*long_LT*AL*(1/o_h(i))^BL;
XLf_pu(i)=XLf(i)/Zbase;
Gf(i)=((1/G)*(1+AR*((1/o_h(i))-1))^BR)^-1;

Zw(i)=sqrt((Rf_pu(i)+1j*XLf_pu(i))/(Gf(i)+1j*2*pi*f_fn*o_h(i)*C*long_LT))
g(i)=long_LT*sqrt((Rf_pu(i)+1j*XLf_pu(i))*(Gf(i)+1j*2*pi*f_fn*o_h(i)*C*long_LT))
/long_LT
Z12(i)=Zw(i)*sinh(g(i))
Zo(i)=Zw(i)*coth(g(i)/2)

end

for i=1:n_h
Pflujo_harmonic(i)=Ve*((Ve-Vr*cos(phi_e-phi_r))*real(Z12(i))+Vr*sin(phi_e-phi_r)*imag(Z12(i)));
Qflujo_harmonic(i)=Ve*((Ve-Vr*cos(phi_e-phi_r))*imag(Z12(i))-Vr*sin(phi_e-phi_r)*real(Z12(i))-Ve*GY(i)/2);

end

Pflujo_f_onda=sum(Pflujo_harmonic);
set(handles.edit24,'string',Pflujo_f_onda);
Qflujo_f_onda=sum(Qflujo_harmonic);
set(handles.edit28,'string',Qflujo_f_onda);

%% THD
aux2=sqrt(sum(Amp_Ih.^2));
THD=aux2*100/Irms_carga;
set(handles.edit25,'string',THD);
%% Gráfica
axes(handles.axes1);
plot(t,i_carga,t,Ires);
title('Análisis de Armónicos en L/T');
legend('Corriente Sin Armónicos','Corriente con Armónicos');
xlabel('Tiempo [s]');
ylabel('Corriente [A]');
grid on

%% Gráfica de barras
axes(handles.axes2);
bar(o_h,Amp,'r');
title('Graficas de barras porcentuales de los armónicos');
xlabel('Orden del armónico');
ylabel('Porcentaje de la corriente nominal');
grid on

% --- Executes on button press in pushbutton2.


function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.edit1,'string','');
set(handles.edit2,'string','');
set(handles.edit3,'string','');
set(handles.edit4,'string','');
set(handles.edit5,'string','');
set(handles.edit6,'string','');
set(handles.edit7,'string','');
set(handles.edit8,'string','');
set(handles.edit9,'string','');
set(handles.edit10,'string','');
set(handles.edit11,'string','');
set(handles.edit12,'string','');
set(handles.edit13,'string','');
set(handles.edit14,'string','');
set(handles.edit15,'string','');
set(handles.edit16,'string','');
set(handles.edit18,'string','');
set(handles.edit19,'string','');
set(handles.edit20,'string','');
set(handles.edit22,'string','');
set(handles.edit23,'string','');
set(handles.edit24,'string','');
set(handles.edit25,'string','');
set(handles.edit26,'string','');
set(handles.edit27,'string','');
set(handles.edit28,'string','');
cla(handles.axes1,'reset');
cla(handles.axes2,'reset')

function edit16_Callback(hObject, eventdata, handles)


% hObject handle to edit16 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit16 as text


% str2double(get(hObject,'String')) returns contents of edit16 as a double

% --- Executes during object creation, after setting all properties.


function edit16_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit16 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit17_Callback(hObject, eventdata, handles)


% hObject handle to edit17 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit17 as text


% str2double(get(hObject,'String')) returns contents of edit17 as a double

% --- Executes during object creation, after setting all properties.


function edit17_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit17 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit18_Callback(hObject, eventdata, handles)


% hObject handle to edit18 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit18 as text


% str2double(get(hObject,'String')) returns contents of edit18 as a double

% --- Executes during object creation, after setting all properties.


function edit18_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit18 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit19_Callback(hObject, eventdata, handles)


% hObject handle to edit19 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit19 as text


% str2double(get(hObject,'String')) returns contents of edit19 as a double

% --- Executes during object creation, after setting all properties.


function edit19_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit19 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit20_Callback(hObject, eventdata, handles)


% hObject handle to edit20 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit20 as text


% str2double(get(hObject,'String')) returns contents of edit20 as a double

% --- Executes during object creation, after setting all properties.


function edit20_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit20 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit22_Callback(hObject, eventdata, handles)


% hObject handle to edit22 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit22 as text


% str2double(get(hObject,'String')) returns contents of edit22 as a double

% --- Executes during object creation, after setting all properties.


function edit22_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit22 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit23_Callback(hObject, eventdata, handles)


% hObject handle to edit23 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit23 as text


% str2double(get(hObject,'String')) returns contents of edit23 as a double

% --- Executes during object creation, after setting all properties.


function edit23_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit23 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit24_Callback(hObject, eventdata, handles)


% hObject handle to edit24 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit24 as text
% str2double(get(hObject,'String')) returns contents of edit24 as a double

% --- Executes during object creation, after setting all properties.


function edit24_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit24 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit25_Callback(hObject, eventdata, handles)


% hObject handle to edit25 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit25 as text


% str2double(get(hObject,'String')) returns contents of edit25 as a double

% --- Executes during object creation, after setting all properties.


function edit25_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit25 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit26_Callback(hObject, eventdata, handles)


% hObject handle to edit26 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit26 as text


% str2double(get(hObject,'String')) returns contents of edit26 as a double

% --- Executes during object creation, after setting all properties.


function edit26_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit26 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit27_Callback(hObject, eventdata, handles)


% hObject handle to edit27 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit27 as text


% str2double(get(hObject,'String')) returns contents of edit27 as a double

% --- Executes during object creation, after setting all properties.


function edit27_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit27 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit28_Callback(hObject, eventdata, handles)


% hObject handle to edit28 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit28 as text


% str2double(get(hObject,'String')) returns contents of edit28 as a double

% --- Executes during object creation, after setting all properties.


function edit28_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit28 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit29_Callback(hObject, eventdata, handles)


% hObject handle to edit29 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit29 as text
% str2double(get(hObject,'String')) returns contents of edit29 as a double

% --- Executes during object creation, after setting all properties.


function edit29_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit29 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

Modelo de la Línea

function varargout = modelo_linea(varargin)


% MODELO_LINEA MATLAB code for modelo_linea.fig
% MODELO_LINEA, by itself, creates a new MODELO_LINEA or raises the existing
% singleton*.
%
% H = MODELO_LINEA returns the handle to a new MODELO_LINEA or the handle to
% the existing singleton*.
%
% MODELO_LINEA('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MODELO_LINEA.M with the given input arguments.
%
% MODELO_LINEA('Property','Value',...) creates a new MODELO_LINEA or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before modelo_linea_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to modelo_linea_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help modelo_linea

% Last Modified by GUIDE v2.5 04-Sep-2020 22:25:02

% Begin initialization code - DO NOT EDIT


gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @modelo_linea_OpeningFcn, ...
'gui_OutputFcn', @modelo_linea_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT

% --- Executes just before modelo_linea is made visible.


function modelo_linea_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to modelo_linea (see VARARGIN)

% Choose default command line output for modelo_linea


handles.output = hObject;

% Update handles structure


guidata(hObject, handles);

% UIWAIT makes modelo_linea wait for user response (see UIRESUME)


% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = modelo_linea_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure


varargout{1} = handles.output;

function e1_Callback(hObject, eventdata, handles)


% hObject handle to e1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of e1 as text


% str2double(get(hObject,'String')) returns contents of e1 as a double

% --- Executes during object creation, after setting all properties.


function e1_CreateFcn(hObject, eventdata, handles)
% hObject handle to e1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function e2_Callback(hObject, eventdata, handles)


% hObject handle to e2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of e2 as text


% str2double(get(hObject,'String')) returns contents of e2 as a double

% --- Executes during object creation, after setting all properties.


function e2_CreateFcn(hObject, eventdata, handles)
% hObject handle to e2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function e3_Callback(hObject, eventdata, handles)


% hObject handle to e3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of e3 as text


% str2double(get(hObject,'String')) returns contents of e3 as a double

% --- Executes during object creation, after setting all properties.


function e3_CreateFcn(hObject, eventdata, handles)
% hObject handle to e3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function e4_Callback(hObject, eventdata, handles)


% hObject handle to e4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of e4 as text


% str2double(get(hObject,'String')) returns contents of e4 as a double
% --- Executes during object creation, after setting all properties.
function e4_CreateFcn(hObject, eventdata, handles)
% hObject handle to e4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

% --- Executes on button press in rb1.


function rb1_Callback(hObject, eventdata, handles)
% hObject handle to rb1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.rb2,'value',1);
set(handles.rb2,'value',0);
set(handles.rb3,'value',0);
set(handles.rb4,'value',0);
set(handles.rb5,'value',0);

set(handles.e6,'string','');
set(handles.e11,'string','');
set(handles.e16,'string','');

set(handles.e7,'string','');
set(handles.e12,'string','');
set(handles.e17,'string','');

set(handles.e8,'string','');
set(handles.e13,'string','');
set(handles.e18,'string','');

set(handles.e9,'string','');
set(handles.e14,'string','');
set(handles.e19,'string','');

set(handles.e5,'enable','on');
set(handles.e10,'enable','on');
set(handles.e15,'enable','on');
set(handles.e6,'enable','off');
set(handles.e11,'enable','off');
set(handles.e16,'enable','off');
set(handles.e7,'enable','off');
set(handles.e12,'enable','off');
set(handles.e17,'enable','off');
set(handles.e8,'enable','off');
set(handles.e13,'enable','off');
set(handles.e18,'enable','off');
set(handles.e9,'enable','off');
set(handles.e14,'enable','off');
set(handles.e19,'enable','off');
% Hint: get(hObject,'Value') returns toggle state of rb1
% --- Executes on button press in rb2.
function rb2_Callback(hObject, eventdata, handles)
% hObject handle to rb2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.rb1,'value',0);
set(handles.rb2,'value',1);
set(handles.rb3,'value',0);
set(handles.rb4,'value',0);
set(handles.rb5,'value',0);

set(handles.e7,'string','');
set(handles.e12,'string','');
set(handles.e17,'string','');

set(handles.e8,'string','');
set(handles.e13,'string','');
set(handles.e18,'string','');

set(handles.e9,'string','');
set(handles.e14,'string','');
set(handles.e19,'string','');

set(handles.e5,'enable','on');
set(handles.e10,'enable','on');
set(handles.e15,'enable','on');
set(handles.e6,'enable','on');
set(handles.e11,'enable','on');
set(handles.e16,'enable','on');
set(handles.e7,'enable','off');
set(handles.e12,'enable','off');
set(handles.e17,'enable','off');
set(handles.e8,'enable','off');
set(handles.e13,'enable','off');
set(handles.e18,'enable','off');
set(handles.e9,'enable','off');
set(handles.e14,'enable','off');
set(handles.e19,'enable','off');
% Hint: get(hObject,'Value') returns toggle state of rb2

% --- Executes on button press in rb3.


function rb3_Callback(hObject, eventdata, handles)
% hObject handle to rb3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.rb1,'value',0);
set(handles.rb2,'value',0);
set(handles.rb3,'value',1);
set(handles.rb4,'value',0);
set(handles.rb5,'value',0);

set(handles.e8,'string','');
set(handles.e13,'string','');
set(handles.e18,'string','');

set(handles.e9,'string','');
set(handles.e14,'string','');
set(handles.e19,'string','');

set(handles.e5,'enable','on');
set(handles.e10,'enable','on');
set(handles.e15,'enable','on');
set(handles.e6,'enable','on');
set(handles.e11,'enable','on');
set(handles.e16,'enable','on');
set(handles.e7,'enable','on');
set(handles.e12,'enable','on');
set(handles.e17,'enable','on');
set(handles.e8,'enable','off');
set(handles.e13,'enable','off');
set(handles.e18,'enable','off');
set(handles.e9,'enable','off');
set(handles.e14,'enable','off');
set(handles.e19,'enable','off');
% Hint: get(hObject,'Value') returns toggle state of rb3

% --- Executes on button press in rb4.


function rb4_Callback(hObject, eventdata, handles)
% hObject handle to rb4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.rb1,'value',0);
set(handles.rb2,'value',0);
set(handles.rb3,'value',0);
set(handles.rb4,'value',1);
set(handles.rb5,'value',0);

set(handles.e9,'string','');
set(handles.e14,'string','');
set(handles.e19,'string','');

set(handles.e5,'enable','on');
set(handles.e10,'enable','on');
set(handles.e15,'enable','on');
set(handles.e6,'enable','on');
set(handles.e11,'enable','on');
set(handles.e16,'enable','on');
set(handles.e7,'enable','on');
set(handles.e12,'enable','on');
set(handles.e17,'enable','on');
set(handles.e8,'enable','on');
set(handles.e13,'enable','on');
set(handles.e18,'enable','on');
set(handles.e9,'enable','off');
set(handles.e14,'enable','off');
set(handles.e19,'enable','off');
% Hint: get(hObject,'Value') returns toggle state of rb4

% --- Executes on button press in rb5.


function rb5_Callback(hObject, eventdata, handles)
% hObject handle to rb5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.rb1,'value',0);
set(handles.rb2,'value',0);
set(handles.rb3,'value',0);
set(handles.rb4,'value',0);
set(handles.rb5,'value',1);
%set(handles.e12,'string','');
set(handles.e5,'enable','on');
set(handles.e10,'enable','on');
set(handles.e15,'enable','on');
set(handles.e6,'enable','on');
set(handles.e11,'enable','on');
set(handles.e16,'enable','on');
set(handles.e7,'enable','on');
set(handles.e12,'enable','on');
set(handles.e17,'enable','on');
set(handles.e8,'enable','on');
set(handles.e13,'enable','on');
set(handles.e18,'enable','on');
set(handles.e9,'enable','on');
set(handles.e14,'enable','on');
set(handles.e19,'enable','on');
% Hint: get(hObject,'Value') returns toggle state of rb5

function e5_Callback(hObject, eventdata, handles)


% hObject handle to e5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of e5 as text
% str2double(get(hObject,'String')) returns contents of e5 as a double
% --- Executes during object creation, after setting all properties.
function e5_CreateFcn(hObject, eventdata, handles)
% hObject handle to e5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function e6_Callback(hObject, eventdata, handles)


% hObject handle to e6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of e6 as text


% str2double(get(hObject,'String')) returns contents of e6 as a double

% --- Executes during object creation, after setting all properties.


function e6_CreateFcn(hObject, eventdata, handles)
% hObject handle to e6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function e7_Callback(hObject, eventdata, handles)


% hObject handle to e7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of e7 as text
% str2double(get(hObject,'String')) returns contents of e7 as a double
% --- Executes during object creation, after setting all properties.
function e7_CreateFcn(hObject, eventdata, handles)
% hObject handle to e7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function e8_Callback(hObject, eventdata, handles)


% hObject handle to e8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of e8 as text
% str2double(get(hObject,'String')) returns contents of e8 as a double
% --- Executes during object creation, after setting all properties.

function e8_CreateFcn(hObject, eventdata, handles)


% hObject handle to e8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))


set(hObject,'BackgroundColor','white');
end

function e9_Callback(hObject, eventdata, handles)


% hObject handle to e9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of e9 as text
% str2double(get(hObject,'String')) returns contents of e9 as a double
% --- Executes during object creation, after setting all properties.

function e9_CreateFcn(hObject, eventdata, handles)


% hObject handle to e9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function e10_Callback(hObject, eventdata, handles)


% hObject handle to e10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of e10 as text


% str2double(get(hObject,'String')) returns contents of e10 as a double

% --- Executes during object creation, after setting all properties.


function e10_CreateFcn(hObject, eventdata, handles)
% hObject handle to e10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function e11_Callback(hObject, eventdata, handles)


% hObject handle to e11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of e11 as text


% str2double(get(hObject,'String')) returns contents of e11 as a double

% --- Executes during object creation, after setting all properties.


function e11_CreateFcn(hObject, eventdata, handles)
% hObject handle to e11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function e12_Callback(hObject, eventdata, handles)


% hObject handle to e12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of e12 as text
% str2double(get(hObject,'String')) returns contents of e12 as a double

% --- Executes during object creation, after setting all properties.


function e12_CreateFcn(hObject, eventdata, handles)
% hObject handle to e12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function e13_Callback(hObject, eventdata, handles)


% hObject handle to e13 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of e13 as text


% str2double(get(hObject,'String')) returns contents of e13 as a double

% --- Executes during object creation, after setting all properties.


function e13_CreateFcn(hObject, eventdata, handles)
% hObject handle to e13 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function e14_Callback(hObject, eventdata, handles)


% hObject handle to e14 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of e14 as text


% str2double(get(hObject,'String')) returns contents of e14 as a double

% --- Executes during object creation, after setting all properties.


function e14_CreateFcn(hObject, eventdata, handles)
% hObject handle to e14 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function e15_Callback(hObject, eventdata, handles)


% hObject handle to e15 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of e15 as text


% str2double(get(hObject,'String')) returns contents of e15 as a double

% --- Executes during object creation, after setting all properties.


function e15_CreateFcn(hObject, eventdata, handles)
% hObject handle to e15 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function e16_Callback(hObject, eventdata, handles)


% hObject handle to e16 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of e16 as text


% str2double(get(hObject,'String')) returns contents of e16 as a double

% --- Executes during object creation, after setting all properties.


function e16_CreateFcn(hObject, eventdata, handles)
% hObject handle to e16 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function e17_Callback(hObject, eventdata, handles)


% hObject handle to e17 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of e17 as text


% str2double(get(hObject,'String')) returns contents of e17 as a double

% --- Executes during object creation, after setting all properties.


function e17_CreateFcn(hObject, eventdata, handles)
% hObject handle to e17 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function e18_Callback(hObject, eventdata, handles)


% hObject handle to e18 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of e18 as text


% str2double(get(hObject,'String')) returns contents of e18 as a double

% --- Executes during object creation, after setting all properties.


function e18_CreateFcn(hObject, eventdata, handles)
% hObject handle to e18 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function e19_Callback(hObject, eventdata, handles)


% hObject handle to e19 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of e19 as text


% str2double(get(hObject,'String')) returns contents of e19 as a double

% --- Executes during object creation, after setting all properties.


function e19_CreateFcn(hObject, eventdata, handles)
% hObject handle to e19 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

% --- Executes on button press in pb1.


function pb1_Callback(~, eventdata, handles)
% hObject handle to pb1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
h=zeros(1,5);
Ih=zeros(1,5);
ah=zeros(1,5);

set(handles.e1,'string','0.0015');
set(handles.e2,'string','0.681');
set(handles.e3,'string','1.819');
set(handles.e4,'string','4');
set(handles.e25,'string','100');

rb1=get(handles.rb1,'value');
rb2=get(handles.rb2,'value');
rb3=get(handles.rb3,'value');
rb4=get(handles.rb4,'value');
rb5=get(handles.rb5,'value');

if rb1==1
a=1;
set(handles.e5,'string','17');
m=get(handles.e5,'string');
h(1,1)=str2double(m);
set(handles.e10,'string','60');
m=get(handles.e10,'string');
Ih(1,1)=str2double(m);
set(handles.e15,'string','20');
m=get(handles.e15,'string');
ah(1,1)=str2double(m);
anh(1,1)=ah(1,1)*pi/180;

set(handles.e6,'string','');
set(handles.e11,'string','');
set(handles.e16,'string','');

set(handles.e7,'string','');
set(handles.e12,'string','');
set(handles.e17,'string','');

set(handles.e8,'string','');
set(handles.e13,'string','');
set(handles.e18,'string','');

set(handles.e9,'string','');
set(handles.e14,'string','');
set(handles.e19,'string','');
end

if rb2==1
a=2;
set(handles.e5,'string','17');
m=get(handles.e5,'string');
h(1,1)=str2double(m);
set(handles.e10,'string','60');
m=get(handles.e10,'string');
Ih(1,1)=str2double(m);
set(handles.e15,'string','20');
m=get(handles.e15,'string');
ah(1,1)=str2double(m);
anh(1,1)=ah(1,1)*pi/180;

set(handles.e6,'string','19');
m=get(handles.e6,'string');
h(1,2)=str2double(m);
set(handles.e11,'string','30');
m=get(handles.e11,'string');
Ih(1,2)=str2double(m);
set(handles.e16,'string','20');
m=get(handles.e16,'string');
ah(1,2)=str2double(m);
anh(1,2)=ah(1,2)*pi/180;

set(handles.e7,'string','');
set(handles.e12,'string','');
set(handles.e17,'string','');

set(handles.e8,'string','');
set(handles.e13,'string','');
set(handles.e18,'string','');

set(handles.e9,'string','');
set(handles.e14,'string','');
set(handles.e19,'string','');

end

if rb3==1
a=3;
set(handles.e5,'string','17');
m=get(handles.e5,'string');
h(1,1)=str2double(m);
set(handles.e10,'string','60');
m=get(handles.e10,'string');
Ih(1,1)=str2double(m);
set(handles.e15,'string','20');
m=get(handles.e15,'string');
ah(1,1)=str2double(m);
anh(1,1)=ah(1,1)*pi/180;

set(handles.e6,'string','19');
m=get(handles.e6,'string');
h(1,2)=str2double(m);
set(handles.e11,'string','30');
m=get(handles.e11,'string');
Ih(1,2)=str2double(m);
set(handles.e16,'string','20');
m=get(handles.e16,'string');
ah(1,2)=str2double(m);
anh(1,2)=ah(1,2)*pi/180;
set(handles.e7,'string','26');
m=get(handles.e7,'string');
h(1,3)=str2double(m);
set(handles.e12,'string','25');
m=get(handles.e12,'string');
Ih(1,3)=str2double(m);
set(handles.e17,'string','20');
m=get(handles.e17,'string');
ah(1,3)=str2double(m);
anh(1,3)=ah(1,2)*pi/180;

set(handles.e8,'string','');
set(handles.e13,'string','');
set(handles.e18,'string','');

set(handles.e9,'string','');
set(handles.e14,'string','');
set(handles.e19,'string','');

end

if rb4==1
a=4;
set(handles.e5,'string','17');
m=get(handles.e5,'string');
h(1,1)=str2double(m);
set(handles.e10,'string','60');
m=get(handles.e10,'string');
Ih(1,1)=str2double(m);
set(handles.e15,'string','20');
m=get(handles.e15,'string');
ah(1,1)=str2double(m);
anh(1,1)=ah(1,1)*pi/180;

set(handles.e6,'string','19');
m=get(handles.e6,'string');
h(1,2)=str2double(m);
set(handles.e11,'string','30');
m=get(handles.e11,'string');
Ih(1,2)=str2double(m);
set(handles.e16,'string','20');
m=get(handles.e16,'string');
ah(1,2)=str2double(m);
anh(1,2)=ah(1,2)*pi/180;

set(handles.e7,'string','26');
m=get(handles.e7,'string');
h(1,3)=str2double(m);
set(handles.e12,'string','25');
m=get(handles.e12,'string');
Ih(1,3)=str2double(m);
set(handles.e17,'string','20');
m=get(handles.e17,'string');
ah(1,3)=str2double(m);
anh(1,3)=ah(1,3)*pi/180;
set(handles.e8,'string','28');
m=get(handles.e7,'string');
h(1,4)=str2double(m);
set(handles.e13,'string','15');
m=get(handles.e12,'string');
Ih(1,4)=str2double(m);
set(handles.e18,'string','30');
m=get(handles.e17,'string');
ah(1,4)=str2double(m);
anh(1,4)=ah(1,3)*pi/180;

set(handles.e9,'string','');
set(handles.e14,'string','');
set(handles.e19,'string','');

end

if rb5==1
a=5;
set(handles.e5,'string','17');
m=get(handles.e5,'string');
h(1,1)=str2double(m);
set(handles.e10,'string','60');
m=get(handles.e10,'string');
Ih(1,1)=str2double(m);
set(handles.e15,'string','20');
m=get(handles.e15,'string');
ah(1,1)=str2double(m);
anh(1,1)=ah(1,1)*pi/180;

set(handles.e6,'string','19');
m=get(handles.e6,'string');
h(1,2)=str2double(m);
set(handles.e11,'string','30');
m=get(handles.e11,'string');
Ih(1,2)=str2double(m);
set(handles.e16,'string','20');
m=get(handles.e16,'string');
ah(1,2)=str2double(m);
anh(1,2)=ah(1,2)*pi/180;

set(handles.e7,'string','26');
m=get(handles.e7,'string');
h(1,3)=str2double(m);
set(handles.e12,'string','25');
m=get(handles.e12,'string');
Ih(1,3)=str2double(m);
set(handles.e17,'string','20');
m=get(handles.e17,'string');
ah(1,3)=str2double(m);
anh(1,3)=ah(1,3)*pi/180;

set(handles.e8,'string','28');
m=get(handles.e7,'string');
h(1,4)=str2double(m);
set(handles.e13,'string','15');
m=get(handles.e12,'string');
Ih(1,4)=str2double(m);
set(handles.e18,'string','30');
m=get(handles.e17,'string');
ah(1,4)=str2double(m);
anh(1,4)=ah(1,4)*pi/180;

set(handles.e9,'string','35');
m=get(handles.e7,'string');
h(1,5)=str2double(m);
set(handles.e14,'string','5');
m=get(handles.e12,'string');
Ih(1,5)=str2double(m);
set(handles.e19,'string','50');
ah(1,5)=str2double(m);
anh(1,5)=ah(1,5)*pi/180;
end

% --- Executes on button press in pb2.


function pb2_Callback(hObject, eventdata, handles)
% hObject handle to pb2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Vb=230*10^3;
Sb=100*10^6;
Zb=(Vb^2)/Sb;

m=get(handles.e1,'string');
Rdc=str2double(m);
m=get(handles.e2,'string');
L=str2double(m);
m=get(handles.e3,'string');
Ci=str2double(m);
m=get(handles.e4,'string');
G=str2double(m);
m=get(handles.e25,'string');
S=str2double(m);

m=get(handles.e5,'string');
h(1,1)=str2double(m);
m=get(handles.e10,'string');
Ih(1,1)=str2double(m);
m=get(handles.e15,'string');
ah(1,1)=str2double(m);
anh(1,1)=ah(1,1)*pi/180;

m=get(handles.e6,'string');
h(1,2)=str2double(m);
m=get(handles.e11,'string');
Ih(1,2)=str2double(m);
m=get(handles.e16,'string');
ah(1,2)=str2double(m);
anh(1,2)=ah(1,2)*pi/180;
m=get(handles.e7,'string');
h(1,3)=str2double(m);
m=get(handles.e12,'string');
Ih(1,3)=str2double(m);
m=get(handles.e17,'string');
ah(1,3)=str2double(m);
anh(1,3)=ah(1,3)*pi/180;

m=get(handles.e8,'string');
h(1,4)=str2double(m);
m=get(handles.e13,'string');
Ih(1,4)=str2double(m);
m=get(handles.e18,'string');
ah(1,4)=str2double(m);
anh(1,4)=ah(1,4)*pi/180;

m=get(handles.e9,'string');
h(1,5)=str2double(m);
m=get(handles.e14,'string');
Ih(1,5)=str2double(m);
m=get(handles.e19,'string');
ah(1,5)=str2double(m);
anh(1,5)=ah(1,5)*pi/180;

rb1=get(handles.rb1,'value');
rb2=get(handles.rb2,'value');
rb3=get(handles.rb3,'value');
rb4=get(handles.rb4,'value');
rb5=get(handles.rb5,'value');

if rb1==1
a=1;
end

if rb2==1
a=2;
end

if rb3==1
a=3;
end

if rb4==1
a=4;
end

if rb5==1
a=5;
end
% Valores de I y V por barra infinita y armónico
for i=1:1:a
Ir(1,i)=-(Ih(1,i)/100)*(cos(anh(1,i))+j*sin(anh(1,i)));
Ir1(1,i)=Ir(1,i);
Vs(1,i)=1; % Barra infinita V=1pu ángulo de 0º
Vs1(1,i)=Vs(1,i);
end
% Por datos de tabla:
ar=0.1;
br=0.8;
al=1;
bl=-0.07;

for i=1:1:a
% Cálculo de los Parametros de la linea para la frecuencia del armonico

Rac=Rdc*((1+0.646*h(1,i)*h(1,i))/(192+0.518*h(1,i)*h(1,i)));
Rf=(Rac*(1+ar*(h(1,i)-1))^br)/Zb;
L1=L*(10^-3)*al*(h(1,i)^bl);
Lf=(2*pi*60*h(1,i)*L1*S)/Zb;
Cf=(2*pi*60*h(1,i)*Ci*(10^-6)*S)/Zb;
Gf=1/((1/(G*(10^-6)*Zb))*(1+ar*(h(1,i)-1))^br);

%% Parametros Distribuidos

Z=Rf+j*Lf;
Y=(Gf/2)+j*(Cf/2);
A1=((Z*Y)/2)-1;
B1=Z;
C1=Y*(1+((Z*Y)/4));
D1=A1;
Vr1(1,i)=(Vs1(1,i)-B1*Ir1(1,i))/A1;
Is1(1,i)=C1*Vr1(1,i)+D1*Ir1(1,i);

Ps1(1,i)=norm(Vs1(1,i))*norm(Is1(1,i))*cos(angle(Vs1(1,i))-angle(Is1(1,i)));
Qs1(1,i)=norm(Vs1(1,i))*norm(Is1(1,i))*sin(angle(Vs1(1,i))-angle(Is1(1,i)));
Pr1(1,i)=norm(Vr1(1,i))*norm(Ir1(1,i))*cos(angle(Vr1(1,i))-angle(Ir1(1,i)));
Qr1(1,i)=norm(Vr1(1,i))*norm(Ir1(1,i))*sin(angle(Vr1(1,i))-angle(Ir1(1,i)));

%% Teoria de ondas

Zw=sqrt((Rf+j*Lf)/(Gf+j*Cf*Zb^2));
g=S*sqrt((Rf+j*Lf)*(Gf+j*Cf*Zb^2));
Z12=Zw*sinh(g);
Z0=Zw*coth(g/2);
A=((Z12*Z0)/2)-1;
B=Z12;
C=Z0*(1+((Z12*Z0)/4));
D=A;
Vr(1,i)=(Vs(1,i)-B*Ir(1,i))/A;
Is(1,i)=C*Vr(1,i)+D*Ir(1,i);
Ps(1,i)=norm(Vs(1,i))*norm(Is(1,i))*cos(angle(Vs(1,i))-angle(Is(1,i)));
Qs(1,i)=norm(Vs(1,i))*norm(Is(1,i))*sin(angle(Vs(1,i))-angle(Is(1,i)));
Pr(1,i)=norm(Vr(1,i))*norm(Ir(1,i))*cos(angle(Vr(1,i))-angle(Ir(1,i)));
Qr(1,i)=norm(Vr(1,i))*norm(Ir(1,i))*sin(angle(Vr(1,i))-angle(Ir(1,i)));
end

PTs1=Ps1(1,1);
PTs=Ps(1,1);
QTs1=Qs1(1,1);
QTs=Qs(1,1);
PTr1=Pr1(1,1);
PTr=Pr(1,1);
QTr1=Qr1(1,1);
QTr=Qr(1,1);
for i=2:1:a

PTs1=PTs1+Ps1(1,i);
PTs=PTs+Ps(1,i);
QTs1=QTs1+Qs1(1,i);
QTs=QTs+Qs(1,i);
PTr1=PTr1+Pr1(1,i);
PTr=PTr+Pr(1,i);
QTr1=QTr1+Qr1(1,i);
QTr=QTr+Qr(1,i);

end
k=0;
h;
for i=1:1:a
isnan(h(i))
if isnan(h(i))==1
k=k+1
end
if isnan(Ih(i))==1
k=k+1
end
if isnan(ah(i))==1
k=k+1
end
if isnan(Rdc)==1
k=k+1;
end
if isnan(L)==1
k=k+1;
end
if isnan(Ci)==1
k=k+1;
end
if isnan(G)==1
k=k+1;
end
if isnan(S)==1
k=k+1;
end

end
if k==0
Pl=PTr-PTs; % ondas
Ql=QTr-QTs; % ondas
Pl1=PTr1-PTs1; %parametros
Ql1=QTr1-QTs1; %parametros

m=num2str(Pl);
set(handles.e20,'string',m);
m=num2str(Ql);
set(handles.e21,'string',m);
m=num2str(Pl1);
set(handles.e22,'string',m);
m=num2str(Ql1);
set(handles.e23,'string',m);
A=transpose(h);
B=transpose(Ih);

A=A(1:a,:);
B=B(1:a,:);
%Gráfico
axes(handles.a1)
bar(A,B);
grid on;
else
msgbox('Ingrese los valores de manera correcta en todas las celdas habiles');
set(handles.e20,'string','');
set(handles.e21,'string','');
set(handles.e22,'string','');
set(handles.e23,'string','');

axes(handles.a1)
bar(0,0);
grid on;

end

function e20_Callback(hObject, eventdata, handles)


% hObject handle to e20 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of e20 as text


% str2double(get(hObject,'String')) returns contents of e20 as a double

% --- Executes during object creation, after setting all properties.

function e20_CreateFcn(hObject, eventdata, handles)


% hObject handle to e20 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function e21_Callback(hObject, eventdata, handles)


% hObject handle to e21 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of e21 as text
% str2double(get(hObject,'String')) returns contents of e21 as a double

% --- Executes during object creation, after setting all properties.


function e21_CreateFcn(hObject, eventdata, handles)
% hObject handle to e21 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function e22_Callback(hObject, eventdata, handles)


% hObject handle to e22 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of e22 as text


% str2double(get(hObject,'String')) returns contents of e22 as a double

% --- Executes during object creation, after setting all properties.


function e22_CreateFcn(hObject, eventdata, handles)
% hObject handle to e22 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function e23_Callback(hObject, eventdata, handles)


% hObject handle to e23 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of e23 as text


% str2double(get(hObject,'String')) returns contents of e23 as a double

% --- Executes during object creation, after setting all properties.


function e23_CreateFcn(hObject, eventdata, handles)
% hObject handle to e23 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function e25_Callback(hObject, eventdata, handles)


% hObject handle to e25 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of e25 as text
% str2double(get(hObject,'String')) returns contents of e25 as a double
% --- Executes during object creation, after setting all properties.

function e25_CreateFcn(hObject, eventdata, handles)


% hObject handle to e25 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

También podría gustarte