You are on page 1of 13

Universidad De Aquino Bolivia Facultad de Ciencia y Tecnologa Ingeniera de Telecomunicaciones

Nombres: Hever Martin Mamani Illanes Docente: Ing. Jaime Flores Semestre: Sexto Fecha: 8 de Abril de 2013

SEALES CONTINUAS Y DISCRETAS


1. OBJETIVO GENERAL: Representar las funciones en tiempo continuo y discreto para graficar y observar el comportamiento de una funcin al variar la frecuencia con la ayuda de diferentes componentes en el GUIDE MATLAB. 2. OBJETIVO ESPECIFICO: Llegar a comprender los componentes del guide-matlab, como ser: Push Button, Slider, Edit Text, Static text, Axes, Panel, Realizar grficos con axes. Usar slider (para ampliar el rango de visin y de frecuencia). 3. ASPECTOS TEORICOS:

SEALES CONTINUAS
Antes de obtener una seal continua en el tiempo, primero se debe crear un vector que represente la secuencia temporal, teniendo el cuidado de elegir un espaciamiento entre muestras apropiado. Por ejemplo para generar seales en el intervalo de tiempo, con muestras tomadas cada 0.05s, escriba en la lnea de comandos: >>T=0.05 Para definir la separacin temporal (en segundos) entre las muestras. Exprese la secuencia temporal que va desde -1 a 1, en pasos T: >>t=[-1:T:1] Observe que todos los elementos del vector t fueron mostrados en la pantalla. Para evitarlo, usualmente se coloca un punto y coma (;) despus de cada instruccin. Para generar la funcin real decreciente x(t)=e-t, escriba: >>x=exp(-t); Dibuje x(t) vs. t: >>plot(t,x,'-y')

El smbolo '-y' indica las caractersticas del trazo: "-" es el tipo de trazo e "y" es el color (en este caso yellow o amarillo). Puede obtener ms informacin de cualquier comando utilice help; por ejemplo si Ud. quiere saber mas detalles del comando plot escriba: >>help plot Pruebe con las diferentes combinaciones de trazos y colores. Calcule la exponencial creciente w(t)=et: >>w=exp(t); Para graficar w(t) existen tres posibilidades : puede dar el comando >>clf Para borrar la figura anterior, o puede dibujar directamente en el espacio disponible lo cual borrar la figura que estaba anteriormente. Tambin puede dibujarlas simultneamente con el comando: >>hold on En cualquiera de los tres casos, dibuje despus w(t) >>plot(t,w,':r') Si desea incluir una cuadrcula en el grfico escriba, luego de hacer el plot: >>grid; para eliminarla escriba nuevamente: >>grid; Cada vez que Ud. desee graficar una nueva figura debe usar la instruccin: >>figure o figure(k) Donde k es el nmero que ser asignado a la figura Calcule y grafique las siguientes funciones con cambios lineales en la escala temporal: x1(t)=e-2t y x2(t)=e-t/2. Dibjelas junto a la seal original x(t). >>x1=exp(-2*t); >>x2=exp(-t/2); >>plot(t,x1,'-y',t,x2,'--g') Observe los siguientes smbolos: '*' para la multiplicacin y '/' para la divisin. Proceda de igual manera para la seal x3(t) = e-2|t|. El valor absoluto de t se calcula con el comando: >>abs(t) Por lo tanto la seal x3 se genera con el siguiente comando: >>x3=exp(-2*abs(t)); >>plot(t,x3,':m')

Ahora graficaremos varias seales en una misma figura pero en espacios diferentes. Para eso se divide primero la figura en una matriz de subgrficos de las dimensiones que uno desee. Imagine que queremos graficar 4 funciones. Dividimos la figura como una matriz de 2x2 y en cada subgrfico aparecer una de las seales. >>subplot(2,2,1); plot(t,x1,'-y'); >>subplot(2,2,2); plot(t,,x2,'--g'); >>subplot(2,2,3); plot(t,x3,'r'); >>subplot(2,2,4); plot(t,x,'-b'); Para generar una seal exponencial compleja y(t)=ej2t escriba en la lnea de comandos: >>y=exp(j*2*pi*t); Observe que 'j' y 'pi' son valores internamente definidos en MATLAB. Corresponden a la unidad imaginaria y al nmero respectivamente. 'i' tambin puede emplearse en lugar de 'j'. Para evitar confusiones se recomienda no usar 'i' ni 'j' como variables. La seal 'y' es compleja, a diferencia de las seales anteriores. Para comprobarlo escriba: >>whos Observe que todas las funciones y valores que se han definido se encuentran disponibles en la memoria. Esto no hace falta si Ud. tiene en la pantalla abierto el workspace. Para observar las partes real e imaginaria de 'y', primero cree una nueva figura o espacio de presentacin: >>figure(2) Luego dibuje las partes real e imaginaria. >>plot(t,real(y),'-b',t,imag(y),':r') Las sinusoides reales tambin pueden ser generadas directamente en MATLAB, por ejemplo si se quieren generar sinusoides se puede usar sin (para Seno) y cos (para Coseno). >>v1=sin(pi*t-pi/6); >>v2=cos(pi*t+pi/4); Ahora generar una seal cuadrada peridica usando la siguiente instruccin: >>cuad=square(2*pi*t); Grafquela: >>plot(t,cuad) Observe que las pendientes no son infinitas. Esto ocurre porque el nmero de puntos es bajo. Haga una prueba usando mas puntos de tiempo (debe definir otro vector de tiempo y volver a graficar). Revise el help de la funcin square.

Ahora generar una seal diente de sierra peridica usando la siguiente instruccin: >>saw=sawtooth(2*pi*t); Grafquela: >>plot(t,saw) Revise el help de esta instruccin. Para finalizar la prctica generaremos un escaln >>escalon=[zeros(1,20) ones(1,21)]; >>plot(t,escalon)

SEALES DISCRETAS
Se le recomienda hacer esta parte de la prctica en un archivo *.m. Antes de continuar borre todos los valores que se encuentran almacenados en memoria: >>clear Esta instruccin tambin puede emplearse para borrar una sola variable. Por ejemplo: >>clear w o ms de una variable: >>clear x, v1, v2 Para generar una seal discreta en el tiempo x[n], primero se debe definir un vector ndice temporal 'n' apropiado. Por ejemplo, para producir una curva exponencial decreciente x[n]=0.9n en el intervalo escriba: >>n=[-10:10] La curva exponencial decreciente x[n] se obtiene escribiendo: >>x=(0.9).^n; Donde '.^ ' representa la operacin de elevar 0.9 a cada uno de los elementos de n. A continuacin grafquela. >>stem(n,x) Obtenga una exponencial creciente: >>w=(1.11).^n; Grafquela: >>stem(n,w)

4. ASPECTOS PRACTICOS: Se mostrara el cdigo y el programa realizado en GUIDE-MATLAB:


function varargout = cont_y_discr(varargin) % CONT_Y_DISCR M-file for cont_y_discr.fig % CONT_Y_DISCR, by itself, creates a new CONT_Y_DISCR or raises the existing % singleton*. % % H = CONT_Y_DISCR returns the handle to a new CONT_Y_DISCR or the handle to % the existing singleton*. % % CONT_Y_DISCR('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in CONT_Y_DISCR.M with the given input arguments. % % CONT_Y_DISCR('Property','Value',...) creates a new CONT_Y_DISCR or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before cont_y_discr_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to cont_y_discr_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 cont_y_discr % Last Modified by GUIDE v2.5 08-Apr-2013 01:25:44 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @cont_y_discr_OpeningFcn, ... 'gui_OutputFcn', @cont_y_discr_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 cont_y_discr is made visible. function cont_y_discr_OpeningFcn(hObject, eventdata, handles, varargin) %se soloca el siguiente codigo para que cuando se haga correr el programa % pueda salir los detalles en el axes1 y axes2 axes(handles.axes1); %desiganamos en q Axes graficar xlabel('Tiempo (t)') %texto en el eje x ylabel('Amplitud') grid off axes(handles.axes2); %desiganamos en q Axes graficar xlabel('Tiempo (t)') ylabel('Amplitud') grid off % Choose default command line output for cont_y_discr handles.output = hObject; % Update handles structure guidata(hObject, handles); function varargout = cont_y_discr_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 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 pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) x=get(handles.slider4,'value'); %se almacena en la variable x el valor %del slider4 de su campo value f=get(handles.slider1,'value'); % en la varible f ingresa el valor del slider1 que %corresponde a la freceuncia t = 0:0.001:x; % define el rango de muestras del eje x o del tiempo y=get(handles.edit1,'String'); %capturamos el valor introducido en el edit1 en su campo string y=char(y); % sirve para que lea todo el caracter de la variable y=eval(y); % evalua la sintaxis de la funcion introducida axes(handles.axes1); %desiganamos en q Axes graficar plot(t,y); %graficamos la funcion en tiempo continuo xlabel('Tiempo (t)'); %texto que se visualiza en el eje "x" ylabel('Amplitud'); %texto que se visualiza en el eje "y" grid on; %muestra las rejillas en el axes1 title('FUNCION EN TIEMPO CONTINUO'); %titulo del axes1 function pushbutton2_Callback(hObject, eventdata, handles) a=' '; %se d un valor de vacio a la variable a para borrar el edit1 set(handles.edit1,'String',a); %mostramos en el edit1 un espacio vacio axes(handles.axes1); %designamos en que axes trabajar (axes1) cla; %borramos el grafico del axes1 function pushbutton5_Callback(hObject, eventdata, handles) close; %salir del programa function slider2_Callback(hObject, eventdata, handles) w=get(handles.slider2,'value'); %almacena en la variable w el valor del slider2 set(handles.text12,'String',w); %muestra en el texto12 en su campo string el valor de w function slider2_CreateFcn(hObject, eventdata, handles) % hObject handle to slider2 (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 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 pushbutton3. function pushbutton3_Callback(hObject, eventdata, handles) x2=get(handles.slider5,'value'); f=get(handles.slider2,'value'); n = 0:0.01:x2; y2=get(handles.edit2,'String'); y2=char(y2); y2=eval(y2); axes(handles.axes2); stem(n,y2); %graficamos la funcion en tiempo discreto xlabel('Tiempo (t)') ylabel('Amplitud') grid on title('FUNCION EN TIEMPO DISCRETO') function pushbutton4_Callback(hObject, eventdata, handles) b=' ' set(handles.edit2,'String',b); axes(handles.axes2); cla;

function slider1_Callback(hObject, eventdata, handles) f=get(handles.slider1,'value'); set(handles.text10,'String',f); % --- 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

% --- Executes on slider movement. function slider5_Callback(hObject, eventdata, handles) x2=get(handles.slider5,'value'); set(handles.text11,'String',fix(x2));

function slider5_CreateFcn(hObject, eventdata, handles) % hObject handle to slider5 (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

% --- Executes on slider movement. function slider4_Callback(hObject, eventdata, handles) x=get(handles.slider4,'value'); set(handles.text9,'String',fix(x)); function slider4_CreateFcn(hObject, eventdata, handles) % hObject handle to slider4 (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

% --- Executes on mouse press over axes background. function axes1_DeleteFcn(hObject, eventdata, handles) % hObject handle to axes1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

% --- Executes on key press with focus on slider4 and none of its controls. function slider4_KeyPressFcn(hObject, eventdata, handles) % --- Executes on slider movement.

Donde se puede observar que el programa est dividido en 2 partes: 1.- Seales continas: Usted podr ingresar la funcin en el edit1 con la variable t como por ejemplo sin(t), sin(2*pi*t), sin(2*pi*t*f), en esta ltima se aade la variable f que representa al valor del slider1, el slider2 maneja el rango de valores para la muestra en funcin del tiempo. 2.- Seales discretas: Usted podr ingresar la funcin que desee en el edit2, pero con la variable n que representa una funcin en tiempo discreto, tambin podemos aadir la variable f para poder utilizar el sider3, y el slider4 usamos para dar el rango de muestras en el eje x Ejemplo de funcionamiento:

5. CONCLUSIONES: Se alcanzo los objetivos planteados y adems se pudo apreciar algunos errores tericos, pero con la ayuda de textos y el internet se puedo corregir los errores, y muestra de ello es el programa terminado bajo los requerimientos encomendados.

6. BIBLIOGRAFIA:
http://catarina.udlap.mx/u_dl_a/tales/documentos/lep/garcia_b_s/capitulo3.pdf http://www.dspace.espol.edu.ec/bitstream/123456789/10740/11/MATLAB_GUIDE.pdf http://ing.ens.uabc.mx/~manuales/electronica/Senales%20y%20Sistemas.pdf

http://www.dspace.espol.edu.ec/bitstream/123456789/10740/11/MATLAB_GUIDE.pdf

You might also like