Вы находитесь на странице: 1из 16

UNIVERSIDADE FEDERAL DE SO JOO DEL-REI

MESTRADO EM ENGENHARIA ELTRICA

PROGAMA DE PS-GRADUAO EM ENGENHARIA


ELTRIA - UFSJ
Modelagem matemtica baseado no adaline
Elaborado por:
Juan Pablo Ochoa Avils
juanochoaaviles@gmail.com
06 DE NOVEMBRO DE 2015

PROGAMA DE PS-GRADUAO EM ENGENHARIA ELTRIA - UFSJ


Mestrado em Engenharia Eltrica

Introduo
Os modelos matemticos devem ser constitudos a partir de dados
observados que descrevam o comportamento do sistema em estudo. Assim,
modelagem matemtica a rea do conhecimento que estuda maneiras de
construir e implementar modelos (matemticos) de sistemas reais.
A motivao para o estudo de tcnicas de identificao de sistemas surge do
fato que frequentemente no se conhecem as equaes envolvidas no
funcionamento de um determinado sistema ou elas so conhecidas, mas seria
impraticvel, por limitaes de tempo e recursos, levantar tais equaes e
estimar seus respectivos parmetros.
O presente trabalho est focado na identificao de um sistema para uma
sonda de temperatura, sendo os valores experimentais para entrada uma
tenso de caraterstica degrau, e para a sada gerada uma variao de
temperatura, para um perodo de amostragem de 2 segundos, isso
observado na figura 1.
Figura 1: Valores da tenso de entrada

200

tenso de entrada
temperatura de saida

Valores medidos para a entrada e a saida

180
160
140
120
100
80
60
40
20
0

200

400

600
800
1000
tempo discreto

1200

1400

1600

A seguir sero apresentados os passos requeridos para conseguir uma


modelagem matemtica que seja a representao do modelo fsico obtido
experimentalmente.

Juan Pablo Ochoa Avils, novembro 2015

PROGAMA DE PS-GRADUAO EM ENGENHARIA ELTRIA - UFSJ


Mestrado em Engenharia Eltrica

Metodologia
A partir dos dados fornecidos, desenhou-se pela ferramenta GUIDE de
MATLAB, uma interface grfica nomeada ARMAX (autoregressive moving
average with exogenous inputs), pelas suas siglas em ingls, mostra-se na
figura 2, a janela principal de controle a qual manipula os dados respeito aos
requerimentos do usurio.
Figura 2: Aplicativo ARMAX

Na zona de aprendizagem possvel determinar os valores para a regresso


tanto para a entrada quanto para a sada, tambm opcional considerar a
validao cruzada e o ajuste automtico da taxa de treino.
Na rea branca, vai se apresentar os valores do erro meio quadrtico por
iterao sendo o limite estabelecido de =0.0001.
Para a estimativa da avaliao, feita aps do aprendizagem, tem-se a
possibilidade de escolher predio a 1 elemento, 5 elementos e elementos.

Juan Pablo Ochoa Avils, novembro 2015

PROGAMA DE PS-GRADUAO EM ENGENHARIA ELTRIA - UFSJ


Mestrado em Engenharia Eltrica

Com a rede treinada e validada o seguinte passo obter a funo de


transferncia H(s), que associa a entrada U(s) com a sada Y(s), o que
conseguisse logo de marcar com o mouse star no ARMAX.
Finalmente sero mostrados os grficos para a rede treinada e a modelagem.

Ajuste automtico da taxa de aprendizado: Analisando os valores


obtidos em cada iterao, e avaliando a diferencia entre os 5 ltimos;
se fosse superior a 0.4, ento o valor de que inicialmente 0.000004,
ser modificado para 1.0002 acima, desse modo segurasse que se cair
num mnimo e este fosse local, vai conseguir sair e continuar na
procura de um mnimo global.

Validao cruzada: Os dados so divididos em 3 grupos


aletoriamente, onde cada um deles tem uma parcela para avaliao e
outra parcela para treino, sendo estas parcelas da mesma dimenso
para cada um dos grupos, aplicasse o adaline para cada um dos grupos
e finalmente conseguido um melhor desempenho j que ao final
todos os dados sero considerados tanto para avaliao e para treino,
assim conseguisse garantir que o erro do treino no ser maior que o
erro da avaliao.
Resultados
Aps alguns execues do algoritmo foram obtidos os dos melhores valores
em funo do erro meio quadrtico, sendo o primeiro para uma regresso de
primeira ordem e o segundo para uma regresso de segunda ordem, os dados
so apresentados na tabela 1.
Tabela 1
Indicadores de desempenho

Ordem

EMQ

1 (T1)

2 (T2)

Vector de
pesos W

H(Z)

0.315741

0.9677
1.2176
-0.5724

-0.5724 z + 1.216
------------------------z - 0.9677

0.277372

-0.1504
1.1178
1.1005
-1.0706
0.6193

0.6193 z^2 - 1.071 z + 1.101


-----------------------------------z^2 - 1.118 z + 0.1504

Juan Pablo Ochoa Avils, novembro 2015

PROGAMA DE PS-GRADUAO EM ENGENHARIA ELTRIA - UFSJ


Mestrado em Engenharia Eltrica

Partindo da funo de transferncia H(Z), atravs da sentencia [N,D] =


d2cm(Nz,Dz,Ts), conseguisse passar do tempo discreto para o tempo
continuo, dito de outro modo, do domnio de Z para o domnio de S, sendo
as funes de transferncia obtidas as seguintes.
Tabela 2
Funes em tempo contnuo

Ordem

H(S)
-0.5724 s + 0.3269
------------------------s + 0.01642

Primeira

0.6193 s^2 - 0.3009 s + 0.364


-------------------------------------s^2 + 0.9472 s + 0.01828

Segunda

Baseados no erro, seria coerente dizer que a resposta da funo de segundo


ordem melhor que a funo de primeiro ordem, nas figuras 3 e 4,
observasse cada uma das respostas no domnio do tempo para as funes de
transferncia obtidas.
Figura 3: Resposta para a funo de segundo ordem
Linear Simulation Results
200
180
160
140

Amplitude

120
100
80
60
40
20
0

200

400

600

800

1000

1200

1400

1600

Time (seconds)

Juan Pablo Ochoa Avils, novembro 2015

PROGAMA DE PS-GRADUAO EM ENGENHARIA ELTRIA - UFSJ


Mestrado em Engenharia Eltrica
Figura 4: Resposta para a funo de primeiro ordem
Linear Simulation Results
200
180
160
140

Amplitude

120
100
80
60
40
20
0

200

400

600

800

1000

1200

1400

1600

Time (seconds)

Por uma inspeo visual das figuras 3 e 4, possvel confirmar o expressado


anteriormente baseados no EQM, que a resposta da funo de transferncia
de segundo ordem uma representao mais aproximada dos dados
experimentais iniciais.
Concluses

Foi possvel obter uma funo temporria que representa o


comportamento do sistema da sonda de temperatura, o que pelo
mtodo clssico teria sido muito complicado.
Um indicador importante o EQM, pois d uma ideia do desempenho
antes de fazer a anlise das funes de transferncia.
Foi de muita utilidade a incluso do ajuste automtico da taxa de
aprendizagem e a validao cruzada, pois o erro diminuiu at valores
que antes eram impossveis.

Bibliografa
Aguirre, L. A. (2007). Introduo identificao de sistemas. Belo Horizonte: UFMG.
CHAPMAN, S. J. (2011). programaao em MATLAB para engenheiros. SAO PAULO: CENAGE
LEARNING.
Ivan Nunez da Silva, D. H. (2010). Redes Neurais Artificiais para engenharia e cincias
aplicadas. So Paulo: Artliber.

Juan Pablo Ochoa Avils, novembro 2015

PROGAMA DE PS-GRADUAO EM ENGENHARIA ELTRIA - UFSJ


Mestrado em Engenharia Eltrica

ANEXOS
Funciones desenvolvidas
function varargout = ARMAX(varargin)
% ARMAX MATLAB code for ARMAX.fig
%
ARMAX, by itself, creates a new ARMAX or raises the existing
%
singleton*.
%
%
H = ARMAX returns the handle to a new ARMAX or the handle to
%
the existing singleton*.
%
%
ARMAX('CALLBACK',hObject,eventData,handles,...) calls the local
%
function named CALLBACK in ARMAX.M with the given input
arguments.
%
%
ARMAX('Property','Value',...) creates a new ARMAX or raises the
%
existing singleton*. Starting from the left, property value
pairs are
%
applied to the GUI before ARMAX_OpeningFcn gets called. An
%
unrecognized property name or invalid value makes property
application
%
stop. All inputs are passed to ARMAX_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 ARMAX
% Last Modified by GUIDE v2.5 10-Nov-2015 01:13:26
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',
mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @ARMAX_OpeningFcn, ...
'gui_OutputFcn', @ARMAX_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 ARMAX is made visible.


function ARMAX_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject
handle to figure

Juan Pablo Ochoa Avils, novembro 2015

PROGAMA DE PS-GRADUAO EM ENGENHARIA ELTRIA - UFSJ


Mestrado em Engenharia Eltrica
% eventdata
% handles
% varargin

reserved - to be defined in a future version of MATLAB


structure with handles and user data (see GUIDATA)
command line arguments to ARMAX (see VARARGIN)

% Choose default command line output for ARMAX


handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes ARMAX wait for user response (see UIRESUME)
% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = ARMAX_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 selection change in popupmenu2.


function popupmenu2_Callback(hObject, eventdata, handles)
% hObject
handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu2
contents as cell array
%
contents{get(hObject,'Value')} returns selected item from
popupmenu2
janela=(get(handles.popupmenu2,'Value'))-1;
guidata(hObject, handles);

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


function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject
handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns
called
% Hint: popupmenu 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 selection change in popupmenu3.


function popupmenu3_Callback(hObject, eventdata, handles)
% hObject
handle to popupmenu3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB

Juan Pablo Ochoa Avils, novembro 2015

PROGAMA DE PS-GRADUAO EM ENGENHARIA ELTRIA - UFSJ


Mestrado em Engenharia Eltrica
% handles

structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu3


contents as cell array
%
contents{get(hObject,'Value')} returns selected item from
popupmenu3

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


function popupmenu3_CreateFcn(hObject, eventdata, handles)
% hObject
handle to popupmenu3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns
called
% Hint: popupmenu 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 selection change in popupmenu4.


function popupmenu4_Callback(hObject, eventdata, handles)
% hObject
handle to popupmenu4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu4
contents as cell array
%
contents{get(hObject,'Value')} returns selected item from
popupmenu4
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function popupmenu4_CreateFcn(hObject, eventdata, handles)
% hObject
handle to popupmenu4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns
called
% Hint: popupmenu 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 selection change in popupmenu5.


function popupmenu5_Callback(hObject, eventdata, handles)
% hObject
handle to popupmenu5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu5
contents as cell array

Juan Pablo Ochoa Avils, novembro 2015

PROGAMA DE PS-GRADUAO EM ENGENHARIA ELTRIA - UFSJ


Mestrado em Engenharia Eltrica
%
contents{get(hObject,'Value')} returns selected item from
popupmenu5

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


function popupmenu5_CreateFcn(hObject, eventdata, handles)
% hObject
handle to popupmenu5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns
called
% Hint: popupmenu 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)
clc
taxa=(get(handles.taxa,'value'));
cruza=(get(handles.validacao,'value'));
eta=0.000004;
eps=0.0001;
tempo=1;
load heating_system.dat;
Y=heating_system(:,3)';
X=heating_system(:,2)';
tg=heating_system(:,1);
trama=length(Y);

ya=Y(1:2*trama/3);
Y1a=Y((trama-trama/3+1):trama);
xa=X(1:2*trama/3);
X1a=X((trama-trama/3+1):trama);
yb=[Y(1:trama/3) Y(2*trama/3+1:trama)];
Y1b=Y((trama/3+1):(2*trama/3));
xb=[X(1:trama/3) X(2*trama/3+1:trama)];
X1b=X((trama/3+1):(2*trama/3));
yc=Y(trama/3+1:trama);
Y1c=Y(1:trama/3);
xc=X(trama/3+1:trama);
X1c=X(1:trama/3);

y=Y(1,1:500);
Y1=Y(1,501:801);
x=X(1,1:500);
X1=X(1,501:801);

Juan Pablo Ochoa Avils, novembro 2015

10

PROGAMA DE PS-GRADUAO EM ENGENHARIA ELTRIA - UFSJ


Mestrado em Engenharia Eltrica

janela =str2double(get(handles.edit1,'string'));
janela1 =str2double(get(handles.edit2,'string'));
pos =get(handles.popupmenu4,'value');
if pos==1
T=1;
end
if pos==2
T=5;
end
if pos==3
T=0;
end
if T>janela
T=janela;
end
if cruza==0
fim=length(y);
i=0;
for i=1:fim-janela
yin(i,:)=y(i:janela+i-1);
yout(i)=y(janela + i);
xin(i,:)=[x(janela-janela1+i:janela+i)];
%
xin(i,:)=[x(janela-janela1+i:janela+i-1), -1];
end
YIN=[yin xin];
[linha1,~]=size(YIN');
w=1*randn(1,linha1);
end
while tempo<4
if cruza == 1
switch tempo
case 1
fim1=length(ya);
i=0;
for i=1:fim1-janela
yin(i,:)=ya(i:janela+i-1);
yout(i)=ya(janela + i);
xin(i,:)=[xa(janela-janela1+i:janela+i)];
%xin(i,:)=[xa(janela-janela1+i:janela+i-1),-1];
end
YIN=[yin xin];
[linha1,~]=size(YIN');
w=1*randn(1,linha1);
case 2
fim2=length(yb);
i=0;
for i=1:fim2-janela
yin(i,:)=yb(i:janela+i-1);
yout(i)=yb(janela + i);
xin(i,:)=[xb(janela-janela1+i:janela+i)];

Juan Pablo Ochoa Avils, novembro 2015

11

PROGAMA DE PS-GRADUAO EM ENGENHARIA ELTRIA - UFSJ


Mestrado em Engenharia Eltrica
%xin(i,:)=[xb(janela-janela1+i:janela+i-1),-1];
end
YIN=[yin xin];
w=W;
case 3
fim3=length(yc);
i=0;
for i=1:fim3-janela
yin(i,:)=yc(i:janela+i-1);
yout(i)=yc(janela + i);
xin(i,:)=[xc(janela-janela1+i:janela+i)];
%xin(i,:)=[xc(janela-janela1+i:janela+i-1),-1];
end
YIN=[yin xin];
w=W;
end
tempo=tempo+1;
else
tempo=4;
end
[ W,iter,eqm,eta ] = adaline(YIN,yout,eta,eps,taxa,w);
end
set(handles.text9,'String',eqm(iter));
fim=length(y);
i=0;
for i=1:fim-janela
yplot(i,:)=y(i:janela+i-1);
%xplot(i,:)=[x(janela-janela1+i:janela+i-1),-1];
xplot(i,:)=[x(janela-janela1+i:janela+i)];
end
Yplot=[yplot xplot];
sal=[y(1,1:janela) W*Yplot'];
tg1=tg(1:500);
figure
plot(tg,Y);
hold on
plot(tg1,sal,'-go','MarkerSize',1);
final=length(Y1);
for i=1:final-janela
YYin(i,:)=Y1(i:janela+i-1);
YYout(i)=Y1(janela + i);
%XXin(i,:)=[X1(janela-janela1+i:janela+i-1),-1];
XXin(i,:)=[X1(janela-janela1+i:janela+i)];
end

base=Y1(1,1:janela);
[c,~]=size(YYin);
YYIN=[YYin XXin];
count = 0;
for j=1:c

Juan Pablo Ochoa Avils, novembro 2015

12

PROGAMA DE PS-GRADUAO EM ENGENHARIA ELTRIA - UFSJ


Mestrado em Engenharia Eltrica
resposta(j)=W*YYIN(j,:)';
count=count+1;
if count == T
for k=1:T
YYin(j+1,janela-T+k)=resposta(j-T+k);
end
count =count - 1;
end
end
time=tg(501:801);
resposta=[base resposta];
xlswrite('W_armax.xlsx',W);
hold on
plot(time,resposta,'-r+','MarkerSize',3);
grid on

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

% --- 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)
A1= str2double(get(handles.edit1,'String'))+1;
set(handles.edit1,'String',A1);

% --- Executes on button press in pushbutton3.


function pushbutton3_Callback(hObject, eventdata, handles)
% hObject
handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
A1= str2double(get(handles.edit1,'String'));

Juan Pablo Ochoa Avils, novembro 2015

13

PROGAMA DE PS-GRADUAO EM ENGENHARIA ELTRIA - UFSJ


Mestrado em Engenharia Eltrica
if A1>0
A1= str2double(get(handles.edit1,'String'))-1;
end
set(handles.edit1,'String',A1);

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

% --- Executes on button press in pushbutton6.


function pushbutton6_Callback(hObject, eventdata, handles)
% hObject
handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
A2= str2double(get(handles.edit2,'String'))+1;
set(handles.edit2,'String',A2);

% --- Executes on button press in pushbutton7.


function pushbutton7_Callback(hObject, eventdata, handles)
% hObject
handle to pushbutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
A2= str2double(get(handles.edit2,'String'));
if A2>0
A2= str2double(get(handles.edit2,'String'))-1;
end
set(handles.edit2,'String',A2);

% --- Executes on button press in taxa.


function taxa_Callback(hObject, eventdata, handles)
% hObject
handle to taxa (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB

Juan Pablo Ochoa Avils, novembro 2015

14

PROGAMA DE PS-GRADUAO EM ENGENHARIA ELTRIA - UFSJ


Mestrado em Engenharia Eltrica
% handles

structure with handles and user data (see GUIDATA)

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

% --- Executes on button press in validacao.


function validacao_Callback(hObject, eventdata, handles)
% hObject
handle to validacao (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of validacao

% --- Executes on button press in pushbutton8.


function pushbutton8_Callback(hObject, eventdata, handles)
% hObject
handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
W=xlsread('W_armax.xlsx');
% janela=2;
% janela1=2;
y0=129;
janela =str2double(get(handles.edit1,'string'));
janela1 =str2double(get(handles.edit2,'string'));
LW=janela + janela1 +1;
grau=janela-janela1;
load heating_system.dat;
Y=heating_system(:,3)';
u=heating_system(:,2);
t=heating_system(:,1);
Ts=2;
Nz=fliplr(W((LW-janela1):(LW)));
Nz=[Nz zeros(1,grau)];
Dz=-fliplr(W((1):(LW-janela1-1)));
Dz=[1 Dz];
[N,D] = d2cm(Nz,Dz,Ts);
%HZ=tf(W(2),[1 -W(1)],2);
H=tf(N,D);
H_sym=evalc('H');
set(handles.text12,'string',H_sym);

figure;
plot(t,Y);
hold on
lsim(H,u,t,y0,'-r');

grid on

function edit4_Callback(hObject, eventdata, handles)

Juan Pablo Ochoa Avils, novembro 2015

15

PROGAMA DE PS-GRADUAO EM ENGENHARIA ELTRIA - UFSJ


Mestrado em Engenharia Eltrica
% hObject
% eventdata
% handles

handle to edit4 (see GCBO)


reserved - to be defined in a future version of MATLAB
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

Juan Pablo Ochoa Avils, novembro 2015

16

Вам также может понравиться