function varargout = ejerap4(varargin) % EJERAP4 M-file for ejerap4.fig % EJERAP4, by itself, creates a new EJERAP4 or raises the existing % singleton*. % % H = EJERAP4 returns the handle to a new EJERAP4 or the handle to % the existing singleton*. % % EJERAP4('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in EJERAP4.M with the given input arguments. % % EJERAP4('Property','Value',...) creates a new EJERAP4 or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before ejerap4_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to ejerap4_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 ejerap4 % Last Modified by GUIDE v2.5 21-Nov-2011 20:56:27 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @ejerap4_OpeningFcn, ... 'gui_OutputFcn', @ejerap4_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 ejerap4 is made visible. function ejerap4_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 ejerap4 (see VARARGIN) %find_system('Name','cuarto'); %open_system('cuarto'); %set_param('cuarto/Ganancia integral','Gain','1'); %set_param('cuarto/Ganancia proporcional','Gain','1'); %set_param('cuarto/Ganancia derivativa','Gain','1'); %set_param(gcs,'SimulationCommand','Start'); % Choose default command line output for ejerap4 handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes ejerap4 wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = ejerap4_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 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) GI=str2num(get(handles.gi,'String')); %Obtenemos la ganancia integral GP=str2num(get(handles.gp,'String')); %Obtenemos la ganancia proporcional GD=str2num(get(handles.gd,'String')); %Obtenemos la ganancia derivativa tiem=str2num(get(handles.tiem,'String')); %Obtenemos el tiempo de simulación fi=tf(1,[1 0]); %Definimos el bloque integral fp=tf(1); %Definimos el bloque de ganancia fd=tf([1 0],1); %Definimos el bloque derivativo fct=GI*fi+GP*fp+GD*fd %función transferencia de control ft=tf(25,[1 4 25]); %función transferencia del sistema a controlar ftt=fct*ft; %función transferencia directa equivalente fte=ftt/(1+ftt) %función transferencia con realimentación unitaria axes(handles.axes1); %se graficará en la misma ventana if (tiem<15) %Se establecen el mínimo intervalos entres dos puntos inte=0.01 %calculados según el tiempo total de la simulación else inte=0.05 end t=0:inte:tiem; %se definen los puntos a graficar lon=length(t); %se obitene la función escalón a graficar escalon=ones([1,lon]) y=step(fte,t) %se obtiene la respuesta al escalón unitario plot(t,y,'-',t,escalon,'-'); %se grafica la respuesta y la exitación legend('Salida','Entrada'); %Se establecen las referencias en el gráfico grid; title('Respuesta al escalón unitario'); %se coloca el título xlabel('t (s)'); % Se etiquetan los ejes ylabel('Amplitud'); function gi_Callback(hObject, eventdata, handles) % hObject handle to gi (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 gi as text % str2double(get(hObject,'String')) returns contents of gi as a double % --- Executes during object creation, after setting all properties. function gi_CreateFcn(hObject, eventdata, handles) % hObject handle to gi (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 gp_Callback(hObject, eventdata, handles) % hObject handle to gp (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 gp as text % str2double(get(hObject,'String')) returns contents of gp as a double % --- Executes during object creation, after setting all properties. function gp_CreateFcn(hObject, eventdata, handles) % hObject handle to gp (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 gd_Callback(hObject, eventdata, handles) % hObject handle to gd (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 gd as text % str2double(get(hObject,'String')) returns contents of gd as a double % --- Executes during object creation, after setting all properties. function gd_CreateFcn(hObject, eventdata, handles) % hObject handle to gd (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 tiem_Callback(hObject, eventdata, handles) % hObject handle to tiem (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 tiem as text % str2double(get(hObject,'String')) returns contents of tiem as a double % --- Executes during object creation, after setting all properties. function tiem_CreateFcn(hObject, eventdata, handles) % hObject handle to tiem (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