You are on page 1of 8

function varargout = proyect3(varargin) % PROYECT3 M-file for proyect3.

fig % PROYECT3, by itself, creates a new PROYECT3 or raises the existing % singleton*. % % H = PROYECT3 returns the handle to a new PROYECT3 or the handle to % the existing singleton*. % % PROYECT3('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in PROYECT3.M with the given input arguments. % % PROYECT3('Property','Value',...) creates a new PROYECT3 or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before proyect3_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to proyect3_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 proyect3 % Last Modified by GUIDE v2.5 07-Jan-2013 20:51:33 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @proyect3_OpeningFcn, ... 'gui_OutputFcn', @proyect3_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 proyect3 is made visible. function proyect3_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 % varargin

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

% Choose default command line output for proyect3 handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes proyect3 wait for user response (see UIRESUME) % uiwait(handles.figure1); set(handles.edit1,'Enable','off') axes(handles.axes1) grid axes(handles.axes2) grid axes(handles.axes3) grid axes(handles.axes4) grid % --- Outputs from this function are returned to the command line. function varargout = proyect3_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) %SEAL SENO P=str2double(get(handles.edit2,'String')); if P<0 || isnan(P) || P>12 errordlg('Escoja un valor entre 1 y 12 para el periodo','ERROR'); return end f=1; t = 0:0.01: P; L=length(t); xa = sin(2*pi*f*t); axes(handles.axes1) plot(t,xa);grid xlabel('Tiempo, ins'); ylabel('Amplitud'); title('Serial continua x_{a}(t)'); axes(handles.axes2);

T = 0.1; n = 0:T: P; xs = sin(2*pi*f*n); k = 0:length(n)-1; stem(k,xs);grid; xlabel('Indice de muestreo'); ylabel('Amplitud');0 title('Seal discreta x[n]'); %RETENCION DE LA SEAL MUESTREADA ret=timeseries(xs,k); ret.name=' Retencion'; ret.timeinfo.units='h'; ret1=ret.setinterpmethod('Zoh'); axes(handles.axes3); plot(ret1); grid on %RECONSTRUCCION FILTRO PASABAJO %Como tenemos la seal muestreada tenemos que reconstruirla por tanto usamos la funcion sinc(x) %que es la funcion seno(x) dividida en x. La funcion sinc(x), de longitud infinita, %genera un filtro pasa-bajo ideal, pero como no podemos generarla al infinito la generaremos de forma %truncada o con limite. nn=0:0.0001:P; xc=sin(2*pi*f*nn); n2=(0:T:P)'; xs=sin(2*pi*f*n2); t=linspace(0,P,P/0.0001)'; ya=sinc((1/T)*t(:,ones(size(n2)))-(1/T)*n2(:,ones(size(t)))')*xs; axes(handles.axes4) plot(n2,xs,'or',t,ya,'m',nn,xc,'--b');grid; legend('Muestras','Reconstruida','Original'); title('Comparacion de las seales') xlabel('Time') ylabel('Amplitude') axis([0 P -1 1]); % --- 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) %SEAL COSENO P=str2double(get(handles.edit2,'String')); if P<0 || isnan(P) || P>12 errordlg('Escoja un valor entre 1 y 12 para el periodo','ERROR'); return end f=1; t = 0:0.01: P; L=length(t); xa = cos(2*pi*f*t); axes(handles.axes1) plot(t,xa);grid xlabel('Tiempo, ins');

ylabel('Amplitud'); title('Serial continua x_{a}(t)'); axes(handles.axes2); T = 0.1; n = 0:T: P; xs = cos(2*pi*f*n); k = 0:length(n)-1; stem(k,xs);grid; xlabel('Indice de muestreo'); ylabel('Amplitud');0 title('Seal discreta x[n]'); %RETENCION DE LA SEAL MUESTREADA ret=timeseries(xs,k); ret.name=' Retencion'; ret.timeinfo.units='h'; ret1=ret.setinterpmethod('Zoh'); axes(handles.axes3); plot(ret1); grid on %RECONSTRUCCION FILTRO PASABAJO %Como tenemos la seal muestreada tenemos que reconstruirla por tanto usamos la funcion sinc(x) %que es la funcion seno(x) dividida en x. La funcion sinc(x), de longitud infinita, %genera un filtro pasa-bajo ideal, pero como no podemos generarla al infinito la generaremos de forma %truncada o con limite. nn=0:0.0001:P; xc=cos(2*pi*f*nn); n2=(0:T:P)'; xs=cos(2*pi*f*n2); t=linspace(0,P,P/0.0001)'; ya=sinc((1/T)*t(:,ones(size(n2)))-(1/T)*n2(:,ones(size(t)))')*xs; axes(handles.axes4) plot(n2,xs,'or',t,ya,'m',nn,xc,'--b');grid; legend('Muestras','Reconstruida','Original'); title('Comparacion de las seales') xlabel('Time') ylabel('Amplitude') axis([0 P -1 1]);

% --- 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) % CUADRATICA P=str2double(get(handles.edit2,'String')); if P<0 || isnan(P) || P>12 errordlg('Escoja un valor entre 1 y 12 para el periodo','ERROR'); return end f=1;

t = 0:0.01: P; L=length(t); xa = square(2*pi*f*t,50); axes(handles.axes1) plot(t,xa,'r');grid xlabel('Tiempo, ins'); ylabel('Amplitud'); title('Serial continua x_{a}(t)'); axes(handles.axes2) T = 0.1; n = 0:T: P; xs = square(2*pi*f*n,50);; k = 0:length(n)-1; stem(k,xs);grid; xlabel('Indice de muestreo'); ylabel('Amplitud');0 title('Seal discreta x[n]'); %RETENCION DE LA SEAL MUESTREADA ret=timeseries(xs,k); ret.name=' Retencion'; ret.timeinfo.units='h'; ret1=ret.setinterpmethod('Zoh'); axes(handles.axes3) plot(ret1,'r'); grid on %RECONSTRUCCION FILTRO PASABAJO %Como tenemos la seal muestreada tenemos que reconstruirla por tanto usamos la funcion sinc(x) %que es la funcion seno(x) dividida en x. La funcion sinc(x), de longitud infinita, %genera un filtro pasa-bajo ideal, pero como no podemos generarla al infinito la generaremos de forma %truncada o con limite. nn=0:0.0001:P; xc=square(2*pi*f*nn,50); n2=(0:T:P)'; xs=square(2*pi*f*n2,50); t=linspace(0,P,P/0.0001)'; ya=sinc((1/T)*t(:,ones(size(n2)))-(1/T)*n2(:,ones(size(t)))')*xs; axes(handles.axes4) plot(n2,xs,'or',t,ya,'m',nn,xc,'--b');grid; legend('Muestras','Reconstruida','Original'); title('Comparacion de las seales') xlabel('Time') ylabel('Amplitude') % --- Executes on button press in pushbutton4. function pushbutton4_Callback(hObject, eventdata, handles) % hObject handle to pushbutton4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) %DIENTE DE SIERRA P=str2double(get(handles.edit2,'String')); if P<0 || isnan(P) || P>12

errordlg('Escoja un valor entre 1 y 12 para el periodo','ERROR'); return end f=1; t = 0:0.01: P; L=length(t); xa = sawtooth(2*pi*f*t); axes(handles.axes1) plot(t,xa);grid xlabel('Tiempo, ins'); ylabel('Amplitud'); title('Serial continua x_{a}(t)'); axes(handles.axes2) T = 0.1; n = 0:T: P; xs = sawtooth(2*pi*f*n);; k = 0:length(n)-1; stem(k,xs);grid; xlabel('Indice de muestreo'); ylabel('Amplitud');0 title('Seal discreta x[n]'); %RETENCION DE LA SEAL MUESTREADA ret=timeseries(xs,k); ret.name=' Retencion'; ret.timeinfo.units='h'; ret1=ret.setinterpmethod('Zoh'); axes(handles.axes3) plot(ret1); grid on %RECONSTRUCCION FILTRO PASABAJO %Como tenemos la seal muestreada tenemos que reconstruirla por tanto usamos la funcion sinc(x) %que es la funcion seno(x) dividida en x. La funcion sinc(x), de longitud infinita, %genera un filtro pasa-bajo ideal, pero como no podemos generarla al infinito la generaremos de forma %truncada o con limite. nn=0:0.0001:P; xc=sawtooth(2*pi*f*nn);; n2=(0:T:P)'; xs=sawtooth(2*pi*f*n2);; t=linspace(0,P,P/0.0001)'; ya=sinc((1/T)*t(:,ones(size(n2)))-(1/T)*n2(:,ones(size(t)))')*xs; axes(handles.axes4) plot(n2,xs,'or',t,ya,'m',nn,xc,'--b');grid; legend('Muestras','Reconstruida','Original'); title('Comparacion de las seales') xlabel('Time') ylabel('Amplitude') % --- Executes on button press in pushbutton5. function pushbutton5_Callback(hObject, eventdata, handles) % hObject handle to pushbutton5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) close

% --- Executes on selection change in popupmenu1. function popupmenu1_Callback(hObject, eventdata, handles) % hObject handle to popupmenu1 (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 popupmenu1 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu1

% --- Executes during object creation, after setting all properties. function popupmenu1_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu1 (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

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

You might also like