informe seÑales continuas y discretas

16
Universidad De Aquino Bolivia Facultad de Ciencia y Tecnología Ingeniería de Telecomunicaciones Nombres: Hever Martin Mamani Illanes Docente: Ing. Jaime Flores Semestre: Sexto Fecha: 8 de Abril de 2013

Upload: hever-mamani

Post on 08-Nov-2014

41 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: INFORME SEÑALES CONTINUAS Y DISCRETAS

Universidad De Aquino BoliviaFacultad de Ciencia y TecnologíaIngeniería de Telecomunicaciones

Nombres:

Hever Martin Mamani Illanes

Docente:

Ing. Jaime Flores

Semestre:

Sexto

Fecha:

8 de Abril de 2013

Page 2: INFORME SEÑALES CONTINUAS Y DISCRETAS

SEÑALES CONTINUAS Y DISCRETAS

1. OBJETIVO GENERAL:

Representar las funciones en tiempo continuo y discreto para graficar y observar el comportamiento de una función 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 gráficos con axes.Usar slider (para ampliar el rango de visión y de frecuencia).

3. ASPECTOS TEORICOS:

SEÑALES CONTINUAS Antes de obtener una señal 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 señales en el intervalo de tiempo, con muestras tomadas cada 0.05s, escriba en la línea de comandos: >>T=0.05

Para definir la separación 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 (;) después de cada instrucción.Para generar la función real decreciente x(t)=e-t, escriba:

>>x=exp(-t);

Dibuje x(t) vs. t:

Page 3: INFORME SEÑALES CONTINUAS Y DISCRETAS

>>plot(t,x,'-y')El símbolo '-y' indica las características del trazo: "-" es el tipo de trazo e "y" es el color (en este caso yellow o amarillo). Puede obtener más información 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. También puede dibujarlas simultáneamente con el comando:

>>hold on

En cualquiera de los tres casos, dibuje después w(t)

>>plot(t,w,':r')

Si desea incluir una cuadrícula en el gráfico escriba, luego de hacer el plot:

>>grid; para eliminarla escriba nuevamente: >>grid;

Cada vez que Ud. desee graficar una nueva figura debe usar la instrucción:

>>figure o figure(k)Donde k es el número 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.Dibújelas junto a la señal original x(t).

>>x1=exp(-2*t);>>x2=exp(-t/2);>>plot(t,x1,'-y',t,x2,'--g')

Observe los siguientes símbolos: '*' para la multiplicación y '/' para la división. Proceda de igual manera para la señal x3(t) = e-2|t|. El valor absoluto de t se calcula con el comando:

>>abs(t)

Por lo tanto la señal x3 se genera con el siguiente comando:

>>x3=exp(-2*abs(t));

Page 4: INFORME SEÑALES CONTINUAS Y DISCRETAS

>>plot(t,x3,':m')Ahora graficaremos varias señales en una misma figura pero en espacios diferentes. Para eso se divide primero la figura en una matriz de subgráficos de las dimensiones que uno desee. Imagine que queremos graficar 4 funciones. Dividimos la figura como una matriz de 2x2 y en cada subgráfico aparecerá una de las señales.

>>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 señal exponencial compleja y(t)=ej2πt escriba en la línea 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 número ð respectivamente. 'i' también puede emplearse en lugar de 'j'.Para evitar confusiones se recomienda no usar 'i' ni 'j' como variables. La señal 'y' es compleja, a diferencia de las señales 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 presentación:

>>figure(2)

Luego dibuje las partes real e imaginaria.

>>plot(t,real(y),'-b',t,imag(y),':r')

Las sinusoides reales también 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 señal cuadrada periódica usando la siguiente instrucción:

>>cuad=square(2*pi*t);

Grafíquela:

>>plot(t,cuad)

Page 5: INFORME SEÑALES CONTINUAS Y DISCRETAS

Observe que las pendientes no son infinitas. Esto ocurre porque el número 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 función square.Ahora generará una señal diente de sierra periódica usando la siguiente instrucción:

>>saw=sawtooth(2*pi*t);

Grafíquela:

>>plot(t,saw)

Revise el help de esta instrucción. Para finalizar la práctica generaremos un escalón

>>escalon=[zeros(1,20) ones(1,21)];>>plot(t,escalon)

SEÑALES DISCRETAS

Se le recomienda hacer esta parte de la práctica en un archivo *.m. Antes de continuar borre todos los valores que se encuentran almacenados en memoria:

>>clear

Esta instrucción también puede emplearse para borrar una sola variable. Por ejemplo:

>>clear w o más de una variable:

>>clear x, v1, v2

Para generar una señal 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 operación de elevar 0.9 a cada uno de los elementos de n. A continuación grafíquela.

>>stem(n,x)

Obtenga una exponencial creciente:

>>w=(1.11).^n;

Page 6: INFORME SEÑALES CONTINUAS Y DISCRETAS

Grafíquela:

>>stem(n,w)4. ASPECTOS PRACTICOS:

Se mostrara el código 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 EDITgui_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

Page 7: INFORME SEÑALES CONTINUAS Y DISCRETAS

[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 axes2axes(handles.axes1); %desiganamos en q Axes graficarxlabel('Tiempo (t)') %texto en el eje xylabel('Amplitud')grid off axes(handles.axes2); %desiganamos en q Axes graficarxlabel('Tiempo (t)')ylabel('Amplitud')grid off% Choose default command line output for cont_y_discrhandles.output = hObject; % Update handles structureguidata(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 structurevarargout{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.

Page 8: INFORME SEÑALES CONTINUAS Y DISCRETAS

% 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 valuef=get(handles.slider1,'value'); % en la varible f ingresa el valor del slider1 que %corresponde a la freceunciat = 0:0.001:x; % define el rango de muestras del eje x o del tiempoy=get(handles.edit1,'String'); %capturamos el valor introducido en el edit1 en su campo stringy=char(y); % sirve para que lea todo el caracter de la variable y=eval(y); % evalua la sintaxis de la funcion introducidaaxes(handles.axes1); %desiganamos en q Axes graficarplot(t,y); %graficamos la funcion en tiempo continuoxlabel('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 axes1title('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 edit1set(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]);

Page 9: INFORME SEÑALES CONTINUAS Y DISCRETAS

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 discretoxlabel('Tiempo (t)')ylabel('Amplitud')grid ontitle('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);

Page 10: INFORME SEÑALES CONTINUAS Y DISCRETAS

% --- 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)

Page 11: INFORME SEÑALES CONTINUAS Y DISCRETAS

% 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.- Señales continúas: Usted podrá ingresar la función 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 añade la variable “f” que representa al valor del slider1, el slider2 maneja el rango de valores para la muestra en función del tiempo.2.- Señales discretas: Usted podrá ingresar la función que desee en el edit2, pero con la variable “n” que representa una función en tiempo discreto, también

Page 12: INFORME SEÑALES CONTINUAS Y DISCRETAS

podemos añadir 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 además se pudo apreciar algunos errores teóricos, 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:

Page 13: INFORME SEÑALES CONTINUAS Y DISCRETAS

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