No BSD License  

Highlights from
CaToKi V2. System Identification ToolKit in Open loop SISO.

image thumbnail

CaToKi V2. System Identification ToolKit in Open loop SISO.

by

 

04 Apr 2007 (Updated )

Is an easy tool for system idenfication of real procces.

CaToKi(varargin)
function varargout = CaToKi(varargin)
% CATOKI M-file for CaToKi.fig
%      CATOKI, by itself, creates a new CATOKI or raises the existing
%      singleton*.
%
%      H = CATOKI returns the handle to a new CATOKI or the handle to
%      the existing singleton*.
%
%      CATOKI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in CATOKI.M with the given input arguments.
%
%      CATOKI('Property','Value',...) creates a new CATOKI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before CaToKi_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to CaToKi_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

% Copyright 2002-2003 The MathWorks, Inc.

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

% Last Modified by GUIDE v2.5 12-Mar-2007 12:35:37

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @CaToKi_OpeningFcn, ...
                   'gui_OutputFcn',  @CaToKi_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 CaToKi is made visible.
function CaToKi_OpeningFcn(hObject, eventdata, handles, varargin)

handles.output = hObject;

% Update handles structure
 axes(handles.axes4);
          cla;
guidata(hObject, handles);
I=imread('chardata.jpg');
 imshow(I)
clc
%  axes(handles.axes4);
%           cla;
% guidata(hObject, handles);
% I=imread('logo.jpg');
%  imshow(I)
%     axes(handles.axes27);
%           cla;
%  I=imread('dryer.jpg');
%   imshow(I)
%            axes(handles.axes14);
%           cla;
% I=imread('chiapas.jpg');
%  imshow(I)
  axes(handles.axes15);
          cla;
 I=imread('logo.jpg');
  imshow(I)
  axes(handles.axes2);
          cla;
 I=imread('logo.jpg');
  imshow(I)
  axes(handles.axes16);
          cla;
 I=imread('logo.jpg');
  imshow(I)
  axes(handles.axes6);
          cla;
 I=imread('logo.jpg');
 imshow(I)
% 
% 
%    axes(handles.axes25);
%           cla;
%  I=imread('arx2.jpg');
%  imshow(I)
%   axes(handles.axes24);
%           cla;
%  I=imread('armax2.jpg');
%  imshow(I)  
%  axes(handles.axes23);
%           cla;
%  I=imread('oe2.jpg');
%  imshow(I)  
%  axes(handles.axes22);
%           cla;
%  I=imread('bj2.png');
%  imshow(I)
% uicontrol_Create(hObject, eventdata, handles)
% selcbk_Create(source,eventdata)
 %%%%%%%inciales
%  handles.na=10;
%  handles.nb=10;
%  handles.nc=10;
% handles.mac=0;
 handles.key=0;
 set(handles.text16,'string','OFF');
guidata(hObject,handles)
% --- Outputs from this function are returned to the command line.
function varargout = CaToKi_OutputFcn(hObject, eventdata, handles) 

varargout{1} = handles.output;


%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                    % SELECT PROCESSS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% --- Executes on selection change in popupmenu9.
function popupmenu9_Callback(hObject, eventdata, handles)



% --- Executes during object creation, after setting all properties.
function popupmenu9_CreateFcn(hObject, eventdata, handles)

if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

set(hObject, 'String', { '1.- Heat-Exchanger Process','2.- Level Process','3.- Flutter Process', '4.- Dryer Process','5.-Heating System','6.- Charge Data'});



% --- Executes on button press in pushbutton24.
function pushbutton24_Callback(hObject, eventdata, handles)

popup_sel_index9 = get(handles.popupmenu9, 'Value');
switch popup_sel_index9
    case 1 
load exchanger.dat
        handles.entrada=exchanger(:,2);
        handles.salida=exchanger(:,3);
        assignin('base','entrada',handles.entrada);
        assignin('base','salida',handles.salida);
        axes(handles.axes4);
        cla;
        guidata(hObject, handles);
        I=imread('exchanger.jpg');
        imshow(I)
    
    case 2
         load nivel.txt
        handles.salida= nivel(:,1);
       Muestras=1023
        handles.entrada=idinput(Muestras,'PRBS',[0 1],[0 1]);
        assignin('base','entrada',handles.entrada);
        assignin('base','salida',handles.salida);
        axes(handles.axes4);
        cla;
        guidata(hObject, handles);
        I=imread('nivel.jpg');
        imshow(I)
    case 3
        load flutter.dat
        handles.entrada=flutter(:,1);
        handles.salida=flutter(:,2);
        assignin('base','entrada',handles.entrada);
        assignin('base','salida',handles.salida);
        axes(handles.axes4);
        cla;
        guidata(hObject, handles);
        I=imread('exchanger.jpg');
        imshow(I)
    case 4
        load dryer.dat
        handles.entrada=dryer(:,1);
        handles.salida=dryer(:,2);
        assignin('base','entrada',handles.entrada);
        assignin('base','salida',handles.salida);
        axes(handles.axes4);
        cla;
        guidata(hObject, handles);
        I=imread('dryer.jpg');
        imshow(I)
    case 5
        load heating_system.dat 
        handles.entrada= heating_system(:,2);
        handles.salida= heating_system(:,3);
        assignin('base','entrada',handles.entrada);
        assignin('base','salida',handles.salida);
        axes(handles.axes4);
        cla;
        guidata(hObject, handles);
        I=imread('exchanger.jpg');
        imshow(I)
    case 6
        load sbpa.txt
        load salida1.txt
           
         handles.entrada= sbpa;
         handles.salida= salida1;
        assignin('base','entrada',handles.entrada);
        assignin('base','salida',handles.salida);
        axes(handles.axes4);
        cla;
        guidata(hObject, handles);
        I=imread('nivel.jpg');
        imshow(I)
end




%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                    % ORDER PANEL
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
 handles.salida=evalin('base', 'salida');
 handles.entrada=evalin('base', 'entrada');
handles.datos=iddata(handles.salida,handles.entrada,handles.Ts);  %%Generating No-parametrical Model
handles.datos.InputName = 'Input Data';
handles.datos.OutputName = 'OutPut Data';
% handles.datosO=resample(handles.datosO,5,1);
% handles.datos=detrend(handles.datos);
%  f=[3 203; 10,250];
%  handles.datos=idfilt(handles.datos,f)
assignin('base','datos',handles.datos) %%Assinig to Workspace
         guidata(hObject,handles)
         
  
function edit1_Callback(hObject, eventdata, handles)
Ts = str2double(get(hObject, 'String'));
if isnan(Ts)
    set(hObject, 'String', 0);
   % errordlg('Input must be a number','Error');
end

handles.Ts=Ts;
%%%
guidata(hObject,handles)

function edit1_CreateFcn(hObject, eventdata, handles)

if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function edit2_Callback(hObject, eventdata, handles)
nk = str2double(get(hObject, 'String'));
if isnan(nk)
    set(hObject, 'String', 0);
   % errordlg('Input must be a number','Error');
end

handles.nk=nk;
%%%
guidata(hObject,handles)

function edit2_CreateFcn(hObject, eventdata, handles)

if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

function edit3_Callback(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
nb = str2double(get(hObject, 'String'));
if isnan(nb)
    set(hObject, 'String', 0);
   % errordlg('Input must be a number','Error');
end

handles.nb=nb;
%%%
guidata(hObject,handles)

% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)

if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

function edit4_Callback(hObject, eventdata, handles)
% hObject    handle to edit4 (see GCBO)
na = str2double(get(hObject, 'String'));
if isnan(na)
    set(hObject, 'String', 0);
   % errordlg('Input must be a number','Error');
end

handles.na=na;
%%%
guidata(hObject,handles)
% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)

if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

function edit5_Callback(hObject, eventdata, handles)
nf = str2double(get(hObject, 'String'));
if isnan(nf)
    set(hObject, 'String', 0);
   % errordlg('Input must be a number','Error');
end

handles.nf=nf;
%%%
guidata(hObject,handles)
% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)

if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

function edit7_Callback(hObject, eventdata, handles)
nc = str2double(get(hObject, 'String'));
if isnan(nc)
    set(hObject, 'String', 0);
   % errordlg('Input must be a number','Error');
end

handles.nc=nc;
%%%
guidata(hObject,handles)

% --- Executes during object creation, after setting all properties.
function edit7_CreateFcn(hObject, eventdata, handles)

if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


function edit8_Callback(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
nd = str2double(get(hObject, 'String'));
if isnan(nd)
    set(hObject, 'String', 0);
   % errordlg('Input must be a number','Error');
end

handles.nd=nd;
%%%
guidata(hObject,handles)

% --- Executes during object creation, after setting all properties.
function edit8_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in intg.  Options botton
function intg_Callback(hObject, eventdata, handles)
% hObject    handle to intg (see GCBO)

ccs_info1 = uicontrol(integ,'Style','push',...
	'Units', 'Normalized','Position', [0.0161 0.0214 0.1071 0.0594 ],  ...
	'BackgroundColor',[0.22 0.33 0.55],...
	'String','Info','Fontsize',11);
	
%%
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                    % Radio Botton  PANEL
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout=radiobutton1_Callback(h, eventdata, handles, varargin)
set (handles.radiobutton1,'value', 1);
set (handles.radiobutton2,'value', 0);
set (handles.radiobutton3,'value', 0);
set (handles.radiobutton4,'value', 0);
function varargout=radiobutton2_Callback(h, eventdata, handles, varargin)
set (handles.radiobutton1,'value', 0);
set (handles.radiobutton2,'value', 1);
set (handles.radiobutton3,'value', 0);
set (handles.radiobutton4,'value', 0);
function varargout=radiobutton3_Callback(h, eventdata, handles, varargin)
set (handles.radiobutton1,'value', 0);
set (handles.radiobutton2,'value', 0);
set (handles.radiobutton3,'value', 1);
set (handles.radiobutton4,'value', 0);
function varargout=radiobutton4_Callback(h, eventdata, handles, varargin)
set (handles.radiobutton1,'value', 0);
set (handles.radiobutton2,'value', 0);
set (handles.radiobutton3,'value', 0);
set (handles.radiobutton4,'value', 1);

% --- Executes on selection change in popupmenu10.
function popupmenu10_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu10 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu10


% --- Executes during object creation, after setting all properties.
function popupmenu10_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

set(hObject, 'String', {'1.- Find nk' '2.- Find na', '3.- Find nb','4.- Find nc', '5.- Find nd ','6.-Find nf','7.- Run Model'});

function pushbutton25_Callback(hObject, eventdata, handles)
% % % uicontrol_Create(hObject, eventdata, handles)
% g=get (handles.radiobutton1,'value');
% g=get (handles.radiobutton2,'value');
% g=get (handles.radiobutton3,'value');
% g=get (handles.radiobutton4,'value');
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                    % ARX MODEL
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (get(handles.radiobutton1,'Value') == 1)
    popup_sel_index10 = get(handles.popupmenu10, 'Value');
switch popup_sel_index10
    case 1 
        
      for nk=0:1:10;
        handles.G1=arx(handles.datos,[handles.na,handles.nb,nk]);
        handles.LF1(1,nk+1)=handles.G1.es.LossFcn;
        handles.x1(1,nk+1)=nk;
      end
     

axes(handles.axes6);
         cla reset;
%          figure(1)
%         subplot(2,2,1)
plot(handles.x1,handles.LF1),title('nk'),grid

guidata(hObject,handles)




case 2
    
     for na=0:1:10;
        handles.G1=arx(handles.datos,[na,handles.nb,handles.nk]);
        handles.LF2(1,na+1)=handles.G1.es.LossFcn;
        handles.x2(1,na+1)=na;
      end
        
        
        
axes(handles.axes15);
         cla reset;
%        figure(1)
%         subplot(2,2,2)
plot(handles.x2,handles.LF2),title('na'),grid

guidata(hObject,handles)

    case 3
       for nb=0:1:10;
        handles.G1=arx(handles.datos,[handles.na,nb,handles.nk]);
        handles.LF3(1,nb+1)=handles.G1.es.LossFcn;
        handles.x3(1,nb+1)=nb;
      end
        
        hold on
axes(handles.axes2);
     cla reset;
%     figure(1)
%         subplot(2,2,3:4)
plot(handles.x3,handles.LF3),title('nb'),grid

guidata(hObject,handles) 
    case 4
        msgbox('If you have already found the  order of the  nk, na and nb polynomials, please select  RUN THE MODEL ')
    case 5
        msgbox('If you have already found the  order of the  nk, na and nb polynomials, please select  RUN THE MODEL ')
    case 6
        msgbox('If you have already found the  order of the  nk, na and nb polynomials, please select  RUN THE MODEL ')
         
    case 7
        
         handles.G1=arx(handles.datos,[handles.na,handles.nb,handles.nk]);
%          figure(2)
%             MRED = balred(handles.G1,2);
%             bode(handles.G1,MRED)
         %         handles.ftARX=d2c(handles.G1(1,:))
         
       assignin('base','ARX',handles.G1);
      assignin('base','modelo',handles.G1);
%        assignin('base','ARX2',MRED);
% %        assignin('base','ftARXc',handles.ftARX);
      handles.G2=handles.G1;
       guidata(hObject,handles)
      axes(handles.axes16);
     cla reset;
     I=imread('logo.jpg');
     imshow(I)
     set(handles.text26,'string','ARX')
     
end


%%
   %%%%%%%%%%%%%%%%%%%%%ARMAX%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

elseif  (get(handles.radiobutton2,'Value') == 1)
    popup_sel_index10 = get(handles.popupmenu10, 'Value');
switch popup_sel_index10

    case 1 
                    
             for nk=1:1:10;
             handles.G1=armax(handles.datos,[handles.na handles.nb handles.na nk]);
            LF1(1,nk+1)= handles.G1.es.LossFcn;
            x1(1,nk+1)=nk;
             end

axes(handles.axes6);
         cla reset;
%         figure(1)
%         subplot(2,2,1)
         plot(x1,LF1),title('nk'),grid

guidata(hObject,handles)

    case 2    
     for na=0:1:10;
        handles.G1=armax(handles.datos,[na,handles.nb,na,handles.nk]);
        handles.LF2(1,na+1)=FPE(handles.G1)
        handles.x2(1,na+1)=na;
      end
        
        hold on
axes(handles.axes15);
         cla reset;
%       figure(1)
%         subplot(2,2,2)
plot(handles.x2,handles.LF2),title('na'),grid

guidata(hObject,handles)

    case 3
    
     for nb=1:10;
        handles.G1=armax(handles.datos,[handles.na,nb,handles.na,handles.nk]);
        handles.LF3(1,nb+1)=FPE(handles.G1);
        handles.x3(1,nb+1)=nb;
      end
        
        hold on
axes(handles.axes2);
     cla reset;
%    figure(1)
%         subplot(2,2,3)
plot(handles.x3,handles.LF3),title('nb'),grid

guidata(hObject,handles)

    case 4
    
     for nc=1:10;
        handles.G1=armax(handles.datos,[handles.na,handles.nb,nc,handles.nk]);
        handles.LF4(1,nc+1)=FPE(handles.G1);
        handles.x4(1,nc+1)=nc;
      end
        
        hold on
axes(handles.axes16);
     cla reset;
     
%             figure(1)
%         subplot(2,2,4)
    plot(handles.x4,handles.LF4),title('nb'),grid

guidata(hObject,handles)
     case 5
        msgbox('If you have already found the  order of the  nk, na and nb polynomials, please select  RUN THE MODEL ')
     case 6
        msgbox('If you have already found the  order of the  nk, na and nb polynomials, please select  RUN THE MODEL ')
     case 7
             
         handles.G1=armax(handles.datos,[handles.na,handles.nb,handles.nc,handles.nk]);
%       handles.ftARX=d2c(handles.G1(1,:))
         handles.G3=handles.G1;
       assignin('base','ARMAX',handles.G1);
       assignin('base','modelo',handles.G1);
%       assignin('base','ftARXMAXc',handles.ftARX);
       guidata(hObject,handles);
       handles.graf=1;
         set(handles.text27,'string','ARMAX')
       guidata(hObject,handles);
     
   
end
     
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%OutPut Error
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif  (get(handles.radiobutton3,'Value') == 1)
popup_sel_index10 = get(handles.popupmenu10, 'Value');

switch popup_sel_index10
    case 1 
        
             for nk=1:1:10;
             handles.G1=oe(handles.datos,[handles.nb handles.nf  nk]);
            handles.LF1(1,nk+1)= handles.G1.es.LossFcn;
            handles.x1(1,nk+1)=nk;
             end
axes(handles.axes6);
         cla reset;
%          figure(1)
%         subplot(2,2,1)
plot(handles.x1,handles.LF1),title('nk'),grid

guidata(hObject,handles)
   case 2
        msgbox('If you have already found the  order of the  nk, nb and nf polynomials, please select  RUN THE MODEL ')
    case 3
    
     for nb=1:10;
        handles.G1=oe(handles.datos,[nb,handles.nf,handles.nk]);
        handles.LF2(1,nb+1)=FPE(handles.G1);
        handles.x2(1,nb+1)=nb;
      end
        
        hold on
axes(handles.axes15);
         cla reset;
%           figure(1)
%         subplot(2,2,2)
plot(handles.x2,handles.LF2),title('nb'),grid

guidata(hObject,handles)

    case 4
    
      msgbox('If you have already found the  order of the  nk, nb and nf polynomials, please select  RUN THE MODEL ')

    case 5
     msgbox('If you have already found the  order of the  nk, nb and nf polynomials, please select  RUN THE MODEL ')
    case 6
        for nf=1:10;
        handles.G1=oe(handles.datos,[handles.nb,nf,handles.nk]);
        handles.LF3(1,nf+1)=FPE(handles.G1);
        handles.x3(1,nf+1)=nf;
      end
        
        hold on
axes(handles.axes2);
     cla reset;
%       figure(1)
%         subplot(2,2,3:4)
plot(handles.x3,handles.LF3),title('nf'),grid

guidata(hObject,handles)
    case 7
       
%  handles.G1 = oe(handles.datos,[1 3],'foc',[0 500])
         handles.G1=oe(handles.datos,[handles.nb,handles.nf,handles.nk]);
         assignin('base','OE',handles.G1);
       assignin('base','modelo',handles.G1);
       handles.G4=handles.G1;
%        assignin('base','ftOEc',handles.ftARX);
       guidata(hObject,handles);
       handles.graf=1;
       guidata(hObject,handles);
       
       O=tf(handles.G1);
       [N,D]=tfdata(O(:,1),'v');
       assignin('base','N',N);
       assignin('base','D',D);
       
    axes(handles.axes16);
     cla reset;
     I=imread('logo.jpg');
     imshow(I);
  set(handles.text29,'string','Output Error');
  
end
       
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%BOB   JENKIS    %BOB   JENKIS    %BOB   JENKIS    %BOB   JENKIS    %BOB   JENKIS     
%%%%%%%%%%%%%%%BOB   JENKIS%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif  (get(handles.radiobutton4,'Value') == 1)
popup_sel_index10 = get(handles.popupmenu10, 'Value');
msgbox('Please follow next steps: 1.- Find nk , 2.- Find nb, 3.- Find nf, 4.- Find nc, 5.- nd=nc')
switch popup_sel_index10
    case 1 
        
               
             for nk=1:10;
             handles.G1=bj(handles.datos,[handles.nb, handles.nb, handles.nb, handles.nf,  nk]);
            handles.LF1(1,nk+1)= handles.G1.es.LossFcn;
            handles.x1(1,nk+1)=nk;
             end

axes(handles.axes6);
         cla reset;
%          figure(1)
%         subplot(2,2,1)
plot(handles.x1,handles.LF1),title('nk'),grid

guidata(hObject,handles)

    case 2 
        msgbox('If you have already found the  order of the  nk, nb,nc, nd and nf polynomials, please select  RUN THE MODEL ')


   case 3
    
     for nb=1:10;
        handles.G1=bj(handles.datos,[nb,nb,nb,handles.nf,handles.nk]);
        handles.LF2(1,nb+1)=FPE(handles.G1);
        handles.x2(1,nb+1)=nb;
      end
        
        hold on
axes(handles.axes15);
         cla reset;
%          figure(1)
%         subplot(2,2,2)
plot(handles.x2,handles.LF2),title('nb'),grid

guidata(hObject,handles)

    

 case 4
    
     for nc=1:10;
        handles.G1=bj(handles.datos,[handles.nb,nc,handles.nb,handles.nf,handles.nk]);
        handles.LF4(1,nc+1)=FPE(handles.G1);
        handles.x4(1,nc+1)=nc;
      end
        
        hold on
axes(handles.axes16);
     cla reset;
     
%             figure(1)
%         subplot(2,2,4)
    plot( handles.x4,handles.LF4),title('nb'),grid

   guidata(hObject,handles)
    case 5
        case 2 
        msgbox('For Optimal resoults nd=nc, or  edit en  Order panel ')

  case 6
    
     for nf=1:10;
        handles.G1=bj(handles.datos,[handles.nb,handles.nb,handles.nb,nf handles.nk]);
        handles.LF3(1,nf+1)=FPE(handles.G1);
        handles.x3(1,nf+1)=nf;
      end
        
%         hold on
axes(handles.axes2);
     cla reset;
%      figure(1)
%         subplot(2,2,3)
plot(handles.x3,handles.LF3),title('nf'),grid

guidata(hObject,handles)     
    case 7
        
        
         handles.G1=bj(handles.datos,[handles.nb,handles.nc,handles.nd,handles.nf,handles.nk]);
       %handles.ftARX=d2c(handles.G1(1,:))
        handles.G5=handles.G1;

%               H=tf([1],[1  0 0]);
%               C=tf(handles.G1)
%              D=d2c(C)
%              handles.G1=D*H;
         assignin('base','BJI',handles.G1);
         assignin('base','modelo',handles.G1);
%       assignin('base','ftBJkc',handles.ftARX);
  set(handles.text28,'string','Box Jenkis')
       guidata(hObject,handles)
       
    
        
        
        
end
         
end

%%
%%%%%%%%%%%%%%%%%MODELOS             MODELOS             MODELOS
%%%%%%%%%%%%%%%%%MODELOS             MODELOS             MODELOS
%%%%%%%%%%%%%%%%%MODELOS             MODELOS             MODELOS
%%%%%%%%%%%%%%%%%MODELOS             MODELOS             MODELOS

% --- Executes on button press in pushbutton4.%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%ARX%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%








% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
 set(handles.text16,'string','ON');
 handles.key=1
  guidata(hObject,handles)
  
  % --- Executes on button press in pushbutton14.
function pushbutton14_Callback(hObject, eventdata, handles)
 set(handles.text16,'string','OFF');
 handles.key=0;
  guidata(hObject,handles)

 


         








%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&%&&&&&&&&&&&&&&&&&&&&&&&&&&

%    PLOTS   PLOTS         GRAFICAS          GRAFICAS         GRAFICAS         GRAFICAS         GRAFICAS          
%%This fuction generte all the plots.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% --- Executes on selection change in popupmenu10.
function popupmenu4_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu10 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu10


% --- Executes during object creation, after setting all properties.
function popupmenu4_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

set(hObject, 'String', {'1.- Input-Output Dates' '2.- SPA and ETFE ', '3.- Step Response','4.- Impulse Response ', '5.- Resid Plots  ','6.- Compare Plot','7.- Fequencial Responce Uncertainly', '8.- Noise Spectrum','9.- Temporal Response Uncertainly  Plot', '10.- Zeros and Poles','11.-Bode Plots'});


function pushbutton12_Callback(hObject, eventdata, handles)


popup_sel_index4 = get(handles.popupmenu4, 'Value');
% handles.G1= evalin('base', 'modelo');
guidata(hObject,handles)
if handles.key==0  
switch popup_sel_index4
    case 1 
        figure(3)
        grid
         plot(handles.datos)%(1:500))
%          grid
%          xlim([0 1000])
    case 2
        figure(3)
%         w = [1:128]/128*pi/0.3;
% g= spa(z,[],w); % (empty matrix gives default)
        G2=spa(handles.datos,80)
        G3=etfe(handles.datos,80)
%         bode(G2,G3)
       ffplot(G2,G3)%'sd',1,'fill') % Showing the uncertainty (3 standard deviations)
       legend('Bode SPA', 'Bode ETFE');
    case 3    
        figure(3) 
       clf
        step(handles.datos)
        hold on
         step(handles.G1,'r')
%         step(handles.G1(:,2))
%        step(handles.dat,handles.G1);

       title('Respuesta al escalon ');
       legend('No Parametrica','Modelo' ),grid
       hold off
        
    case 4 
      figure(3)
        clf
             
 [orale,tiemp1]=impulse(handles.G1);
       [orale2]=impulse(handles.datos);
       [orale2,tiemp]=impulse(orale2(1 ,1));
      
       hold on
       plot(tiemp1,orale,'b')
       plot(tiemp,orale2,'r')
      
    title('Respuesta al impulso ')
    legend('Modelo','No Parametrica','Location', 'northwest' ),grid% %
    hold off  
    
    case 5 
        
        figure(3)
      clf
      subplot(2,2,1)
     resid(handles.datos,handles.G1);%,'fr');
     
   %plot(b)
      %title('Grafica de Residuos');
    case 6
        
   figure(3)
    clf
        
   compare(handles.datos,handles.G1);
%    plot(yesno),title('Error'); 
    case 7  
      figure(3)
     clf
    [g,fiv] = th2ff (handles.G1);
    assignin('base','incertidumbre',g);
   %bodeplot
   ffplot(g,2);title('incertidumbre en la respuesta frecuencial');
    case 8
   figure(3)
   clf
   [g,fiv] = th2ff (handles.G1);
   plot(fiv),title('noise spectrum');  
    case 9
        figure(3)
        clf
        idsimsd (handles.entrada,handles.G1);
        title('Incertidumbre en la respuesta temporal');
    case 10
        figure(3)
     ceropolo =th2zp(handles.G1);
     zpplot(ceropolo);title('Incertidumbre Interna')
    case 11
        figure(3)
        clf
         GB=etfe(handles.datos,80)
        GB2=spa(handles.datos,80)
         ffplot(handles.G1,handles.datos,'sd',0.09,'fill') % Showing the uncertainty (3 standard deviations)
legend('Modelo','No Parametrica','Location', 'northwest' )
         
         %     case  12
%         figure(3)
%         clf
%        [numa,dnea]=tfdata(handles.G1)
%      handles.yarx=dlsim(numa,dnea,handles.entrada)
%      plot(handles.yarx,)
%      xlimit
end
else

%%%%%%%%%%%%%%%%%%%%%%%%COMPARATIVAS%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

switch popup_sel_index4
    case 1 
                 
        errordlg('Thi plot is not diponible in comparatives','Error')
        beep
        
    case 2
        
        
        
         errordlg('Thi plot is not diponible in comparatives','Error')
         beep
    case 3    
        figure(3) 
       clf
          
       step(handles.G2,'c',handles.G3,'b',handles.G4,'g',handles.G5,'y',handles.datos,'r');
       title('Respuesta al escalon ARX');
       legend('ARX','ARMAX','OUTPUT ERROR','BJ','No Parametrica' ,'location','northwest'),grid
       
        
    case 4
      figure(3)
        clf
             
 [orale,tiemp1]=impulse(handles.G2);
 [oralea,tiemp2]=impulse(handles.G3);
 [oraleb,tiemp3]=impulse(handles.G4);
 [oralec,tiemp4]=impulse(handles.G5);
       [orale2]=impulse(handles.datos);
       [orale2,tiemp]=impulse(orale2(1 ,1));
      
       hold on
       plot(tiemp1,orale,'c')
      plot(tiemp2,oralea,'b')
      plot(tiemp3,oraleb,'g')
      plot(tiemp4,oralec,'y')
       plot(tiemp,orale2,'r')
      %xlimit([0 500])
    title('Respuesta al impulso ARX')
    legend('ARX','ARMAX','OUTPUT ERROR','BJ','Non- Parametric','location','Southeast' ),grid
    hold off  
    
    case 5 
        errordlg('Thi plot is not diponible in comparatives','Error')
        beep;
        
    case 6
        
   figure(3)
    clf
        
   compare(handles.datos,handles.G2,handles.G3,handles.G4,handles.G5);
   %xlim([100 200])
  
title(' ARX: AZUL.........ARMAX : VERDE........OUTPUT ERROR: ROJO.......BJ: CIAN'  ),
    grid
%    plot(yesno),title('Error'); 
    case 7  
            
     errordlg('Thi plot is not diponible in comparatives','Error')
     beep;
    case 8
   figure(3)
   clf
  % bode
   ffplot(handles.G2('noise'),handles.G2('n'),handles.G3('n'),handles.G4('n')) 
 
   legend('ARX','ARMAX','OUTPUT ERROR','BJ','Non- Parametric' ,'location','northwest'),grid
   
    case 9
        figure(3)
        clf
       errordlg('Thi plot is not diponible in comparatives','Error')
       beep;
    case 10
         figure(3)
         clf
            GB=spa(handles.datos)
       nyquist(handles.G2,handles.G3,handles.G4,handles.G4,handles.G5,GB)
       legend('ARX','ARMAX','OUTPUT ERROR','BJ','No Parametrica' ),grid
%                ceropolo =th2zp(handles.G2,handles.G2,handles.G3,handles.G4,handles.G5);
%       zpplot(ceropolo);title('Incertidumbre Interna')
    case 11
        figure(3)
        clf
         GB=spa(handles.datos)
        ffplot(handles.G2,handles.G3,handles.G4,handles.G4,handles.G5,GB)
       legend('ARX','ARMAX','OUTPUT ERROR','BJ','No Parametrica' ),grid

        grid
        % Showing the uncertainty (3 standard deviations)
end

end






% --- Executes on button press in pushbutton15.
function pushbutton15_Callback(hObject, eventdata, handles)

% axes(handles.axes6);
%          cla reset;
% axes(handles.axes2);
%          cla reset;
% axes(handles.axes15);
%          cla reset;
% axes(handles.axes16);
%          cla reset;

  axes(handles.axes15);
          cla reset;
 I=imread('logo.jpg');
  imshow(I)
  axes(handles.axes2);
          cla reset;
 I=imread('logo.jpg');
  imshow(I)
  axes(handles.axes16);
          cla reset;
 I=imread('logo.jpg');
  imshow(I)
  axes(handles.axes6);
          cla reset;
 I=imread('logo.jpg');
 imshow(I)
handles.x1=0;
handles.x2=0;
handles.x3=0;
handles.x4=0;

% --- Executes on button press in f3.
function f3_Callback(hObject, eventdata, handles)
figure(4)
subplot(2,2,3)
plot(handles.x3,handles.LF3),grid


% --- Executes on button press in f4.
function f4_Callback(hObject, eventdata, handles)
figure(4)
subplot(2,2,4)
plot( handles.x4,handles.LF4),grid

% --- Executes on button press in f1.
function f1_Callback(hObject, eventdata, handles)
figure(4)
subplot(2,2,1)
plot(handles.x1,handles.LF1),title('nk'),grid


% --- Executes on button press in f2.
function f2_Callback(hObject, eventdata, handles)
figure(4)
subplot(2,2,2)
plot(handles.x2,handles.LF2),grid



% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)

close all;


% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)

g=0;
assignin('base','ARMAX','Model Clear');
assignin('base','ARX','Model Clear');
assignin('base','BJI','Model Clear');
assignin('base','OE','Model Clear');

set(handles.text26,'string','.');
set(handles.text27,'string','.');
set(handles.text28,'string','.');
set(handles.text29,'string','.');
clear 
clc;

function pushbutton27_Callback(hObject, eventdata, handles)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%MENU%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject    handle to slider1 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider


% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% function HelpButton_Callback(hObject, eventdata, handles)
% HelpPath = which('f14ex_help.html');
% web(HelpPath);


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


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


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


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


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


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


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


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


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


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


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


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


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


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


Contact us