TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

34
UNIVERSIDAD POLITECNICA SALESIANA INGENIERIA ELECTRICA SEÑALES Y SITEMAS PRACTICA 2 ALEX PEREZ QUITO- ECUADOR 10-07-2010

Transcript of TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

Page 1: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

UNIVERSIDAD POLITECNICA SALESIANA

INGENIERIA ELECTRICA

SEÑALES Y SITEMAS

PRACTICA 2

ALEX PEREZ

QUITO- ECUADOR

10-07-2010

Page 2: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE Implementar las siguientes funciones: Función desplazamiento

function[y,n]= sigshift(x,m,n0) n =m-n0; y=x; Función inversión

function [y,n] = sigfold(x,n) y = fliplr(x) n=-fliplr(n) EL comando fliplr gira un vector de derecha a izquierda, realizar el siguiente ejemplo en el prompt.

function[y,n]= escale(x,m,p) n =m*(1/p); y=x; Función para sumar señales discretas

function[y,n]= sigadd(x1,n1,x2,n2) %implementación de la función y =x1(n)+x2(n) n = min(min(n1),min(n2)):max(max(n1),max(n2)) y1 =zeros(1,length(n)) y2 = zeros(1,length(n)) y1(find(((n>=min(n1))&(n<=max(n1))==1)))=x1 y2(find (((n>=min(n2))&(n<=max(n2))==1)))=x2 y = y1+y2

Page 3: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

1. Para la señal de la figura obtener las siguientes transformaciones de la variable independiente a. X(t-2) b. X(t+2) c. X(-t) d. X(2t) Función a graficar t=-5:0.001:5 x= stepcont(-2,-5,5) plot(t,x)

a. Señal x(t-2)

Page 4: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

t=-5:0.001:5 x= stepcont(-2,-5,5) [x1,t1]= sigshift(x,t,-2) plot(t1,x1)

d. X(2t) t=-5:0.001:5 x= stepcont(-2,-5,5) [x1,t1]= escale(x,t,2) plot(t1,x1)

Page 5: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

2. Utilizando el comando subplot dibujar en una sola grafica, utilizando el comando title poner los títulos respectivos a cada grafica. t=-5:0.001:5 x= stepcont(-2,-5,5) [x1,t1]= sigshift(x,t,-2) subplot(2,2,1), plot(t1,x1);axis([-5 5 -1 2]); title x(t-2) grid on t=-5:0.001:5 x= stepcont(-2,-5,5) [x1,t1]= sigshift(x,t,2) subplot(2,2,2), plot(t1,x1);axis([-5 5 -1 2]); title x(t+2) grid on t=-5:0.001:5 x= stepcont(-2,-5,5) [x1,t1]= sigfold(x,t) subplot(2,2,3), plot(t1,x1);axis([-5 5 -1 2]); title x(-t) grid on t=-5:0.001:5 x= stepcont(-2,-5,5) [x1,t1]= escale(x,t,2) subplot(2,2,4), plot(t1,x1);axis([-5 5 -1 2]); title x(2t) grid on

Page 6: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

3. Crear una función denominada inversión, que permita invertir una señal en el eje x, y luego elaborar un script para encontrar la señal –x(-t) del ejemplo anterior. function [y,n] = sigfoldi(x,n) y = fliplr(-x) n=-fliplr(n) t=-5:0.001:5

Page 7: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

4. Repetir el ejercicio 2 pero con una señal discreta n=-5:1:5 x= stepseq(-2,-5,5)

n=-5:1:5 x= stepseq(-2,-5,5) [x1,n1]= sigshift(x,n,-2) stem(n1,x1)

Page 8: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

n=-5:1:5 x= stepseq(-2,-5,5) [x1,n1]= sigshift(x,n,2) stem(n1,x1)

n=-5:1:5 x= stepseq(-2,-5,5) [x1,n1]= sigfold(x,n) stem(n1,x1

Page 9: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

n=-5:1:5 x= stepseq(-2,-5,5) [x1,n1]= escale(x,n,2) stem(n1,x1

Page 10: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

5. Suma de señales análogas En ocasiones se desea construir una señal por tramos supongamos la siguiente

Se utiliza para señales analógicas el siguiente script t1=0:0.01:1; % señal x1=t y1= t1 t2=1.01:0.01:2 % señal x2= t y2=2-t2 t = min(min(t1),min(t2)):0.01:max(max(t1),max(t2)) % determinacion de el rango en tiempo t y=[y1 y2] % union d elas dos señales subplot(3,1,1), plot(t1,y1) subplot(3,1,2), plot(t2,y2) subplot(3,1,3), plot(t,y)

Page 11: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

Para señales discretas se puede utilizar la función sigadd 6. Realizar las transformaciones en el tiempo de todos los ejercicios y pruebas realizados en clase x=sen (t)

x= sen(-t)

Page 12: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

x=sen(t/2)

Page 13: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

x=sen(2t)

x=(sin(t)+sin(-t))/2

Page 14: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

x=(sin(t)-sin(-t))/2

x=exp(i*2*t)+exp(i*3*t)

Page 15: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

7. Resolver el ejemplo 7.3 el libro Circuitos Eléctricos de Nilsson 7 edición, pagina 286 y realizar el gráfico en matlab de la señal x(t)= función obtenida al resolver el ejercicio

El conmutador del circuito como se muestra en la figura ha estado en posición x durante un largo periodo de tiempo. En t=0, el conmutador se mueve instantáneamente a la posición y. Calcule

% Voltaje de salida % B= amplitud % a= valor del exponente

Page 16: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

% tiempo B=60; a=25; t=0:0.001:1; x=B*exp(-a*t); plot(t,x)

% Corriente de salida % B= amplitud % a= valor del exponente % tiempo B=60; a=25; t=0:0.001:1; x=B*exp(-a*t); plot(t,x)

Page 17: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

8. Obtener

a. X(-t) t=-5:0.001:5 B=1; a=25; t=0:0.001:1; x=B*exp(-a*t); [x1,t1]= sigfold(x,t) plot(t1,x1) title x(-t)

Page 18: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

b. X(t-2) t=-5:0.001:5 B=1; a=25; t=0:0.001:1; x=B*exp(-a*t); [x1,t1]= sigshift(x,t,-2) plot(t1,x1) title x(t-2)

Page 19: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

c. X(-t+3) t=-5:0.001:5 B=1; a=25; t=0:0.001:1; x=B*exp(-a*t); [x1,t1]= sigshift(x,-t,3) plot(t1,x1) title x(-t+3)

Page 20: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

d. X(t/2) t=-5:0.001:5 B=1; a=25; t=0:0.001:1; x=B*exp(-a*t); [x1,t1]= escale(x,t,1/2) plot(t1,x1) title x(t/2)

Page 21: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

9. Visitar el siguiente enlace, descargar el programa y crear un ejemplo propio que utilice todas las opciones http://www.matpic.com/MATLAB/MATLAB_OOS.html

FUNCION OOS function varargout = OOS(varargin) % Begin initialization code gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @OOS_OpeningFcn, ... 'gui_OutputFcn', @OOS_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 % --- Executes just before OOS is made visible. function OOS_OpeningFcn(hObject, eventdata, handles, varargin) set(gcf,'Color',[.5 1 .5]); handles.t=-1:1/1000:1; t=handles.t; axes(handles.axes1) plot(t,sin(2*pi*4*t),'LineWidth',1.5) axis([-1 1 -1.5 1.5]) grid on axes(handles.axes2) plot(t,sin(2*pi*8*t),'LineWidth',1.5)

Page 22: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

axis([-1 1 -1.5 1.5]) grid on handles.out1=sin(2*pi*5*t); handles.out2=sin(2*pi*8*t); handles.out11=sin(2*pi*5*t); axes(handles.axes3) handles.result=handles.out1+handles.out2; plot(t,handles.result,'LineWidth',1.5,'Color','r') grid on axis([-1 1 -2.5 2.5]) set(handles.amplitude,'Value',0.5); set(handles.time,'Value',0.5); grid on % Choose default command line output for OOS handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes OOS wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = OOS_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 selection change in selector1. function selector1_Callback(hObject, eventdata, handles) % Hints: contents = get(hObject,'String') returns selector1 contents as cell array % contents{get(hObject,'Value')} returns selected item from selector1 v=get(hObject,'Value'); if v==1 %s1 handles.out1=sin(2*pi*5*handles.t); elseif v==2 %c1 handles.out1=cos(2*pi*4*handles.t); elseif v==3 %u1 handles.out1=ustep(2*pi*4*handles.t); elseif v==4 %r1 handles.out1=uramp(handles.t); elseif v==5 %p1 handles.out1=ustep(2*pi*4*(handles.t+.5))-ustep(2*pi*4*(handles.t-0.5));

Page 23: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

end axes(handles.axes1) plot(handles.t,handles.out1,'LineWidth',1.5); axis([-1 1 -1.5 1.5]) grid on guidata(hObject,handles) % --- Executes on selection change in selector2. function selector2_Callback(hObject, eventdata, handles) v=get(hObject,'Value'); axes(handles.axes2) if v==1 %s1 handles.out2=sin(2*pi*5*handles.t); elseif v==2 %c1 handles.out2=cos(2*pi*4*handles.t); elseif v==3 %u1 handles.out2=ustep(2*pi*4*handles.t); elseif v==4 %r1 handles.out2=uramp(handles.t); elseif v==5 %p1 handles.out2=ustep(2*pi*4*(handles.t+.5))-ustep(2*pi*4*(handles.t-0.5)); end plot(handles.t,handles.out2,'LineWidth',1.5); axis([-1 1 -1.5 1.5]) grid on guidata(hObject,handles) % --- Executes on selection change in popupmenu3. function popupmenu3_Callback(hObject, eventdata, handles) axes(handles.axes3); a=get(hObject,'Value'); t=handles.t; if a==2 handles.result=handles.out1.*handles.out2; handles.plot=plot(t,handles.result,'LineWidth',1.5,'Color','r'); else handles.result=handles.out1+handles.out2; handles.plot=plot(t,handles.result,'LineWidth',1.5,'Color','r'); end axis([-1 1 -2.5 2.5]) grid on % --- Executes on slider movement. function amplitude_Callback(hObject, eventdata, handles) f1=1.5*get(handles.time,'Value'); a1=1.5*get(handles.amplitude,'Value'); d1=get(handles.displacement,'Value');

Page 24: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

set(handles.lcd1,'String',a1); axes(handles.axes3) v=get(handles.selector1,'value'); if v==1 handles.out11=a1*sin(2*pi*5*handles.t/f1+d1); elseif v==2 handles.out11=a1*cos(2*pi*4*handles.t/f1+d1); elseif v==3 handles.out11=a1*ustep(2*pi*4*handles.t/f1+d1); elseif v==4 handles.out11=a1*uramp(handles.t/f1+d1); elseif v==5 %p1 handles.out11=a1*(ustep(2*pi*4*(handles.t+f1*.5)+d1)-ustep(2*pi*4*(handles.t-f1*.5)+d1)); end plot(handles.t,handles.out11,'r','LineWidth',1.5); axis([-1 1 -2.5 2.5]) grid on % Update handles structure guidata(hObject, handles); % --- Executes on slider movement. function time_Callback(hObject, eventdata, handles) f1=1.5*get(handles.time,'Value'); a1=1.5*get(handles.amplitude,'Value'); d1=get(handles.displacement,'Value'); set(handles.lcd2,'String',f1); axes(handles.axes3) v=get(handles.selector1,'value'); if v==1 handles.out11=a1*sin(2*pi*5*handles.t/f1+d1); elseif v==2 handles.out11=a1*cos(2*pi*4*handles.t/f1+d1); elseif v==3 handles.out11=a1*ustep(2*pi*4*handles.t/f1+d1); elseif v==4 handles.out11=a1*uramp(handles.t/f1+d1); elseif v==5 %p1 handles.out11=a1*(ustep(2*pi*4*(handles.t+f1*.5)+d1)-ustep(2*pi*4*(handles.t-f1*.5)+d1)); end plot(handles.t,handles.out11,'r','LineWidth',1.5); axis([-1 1 -2.5 2.5]) grid on % Update handles structure guidata(hObject, handles); % --- Executes on slider movement.

Page 25: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

function displacement_Callback(hObject, eventdata, handles) f1=1.5*get(handles.time,'Value'); a1=1.5*get(handles.amplitude,'Value'); d1=get(handles.displacement,'Value'); set(handles.lcd3,'String',d1); axes(handles.axes3) v=get(handles.selector1,'value'); if v==1 handles.out11=a1*sin(2*pi*5*handles.t/f1+d1); elseif v==2 handles.out11=a1*cos(2*pi*4*handles.t/f1+d1); elseif v==3 handles.out11=a1*ustep(2*pi*4*handles.t/f1+d1); elseif v==4 handles.out11=a1*uramp(handles.t/f1+d1); elseif v==5 %p1 handles.out11=a1*(ustep(2*pi*4*(handles.t+f1*.5)+d1)-ustep(2*pi*4*(handles.t-f1*.5)+d1)); end plot(handles.t,handles.out11,'r','LineWidth',1.5); axis([-1 1 -2.5 2.5]) grid on % Update handles structure guidata(hObject, handles); % --- Executes on button press in mirror. function mirror_Callback(hObject, eventdata, handles) v=get(hObject,'Value'); if v==1 handles.t=sort(handles.t,'descend'); else handles.t=sort(handles.t,'ascend'); end axes(handles.axes3) plot(handles.t,handles.out11,'r','LineWidth',1.5); axis([-1 1 -2.5 2.5]) grid on FUNCION USTEP ………………………………….. function y=ustep(t,a) % USTEP Unit Step Function. % % Y=URECT(T) generates a step function with u(0) = 1. % Y=USTEP(T,A) generates a step function with u(0) = A. % % USTEP (with no input arguments) invokes the following example: % % % generate a DT rectangular pulse between n=3 and n=7

Page 26: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

% >>n=0:12; % >>yn=ustep(n-3) - ustep(n-8); % note n-8, not n-7 % >>dtplot(n,yn,'o') %plus other axis commands % % See Also: UDELTA, URAMP, URECT, TRI if nargin==0, help ustep disp('Strike a key to see results of the example') pause nn=0:12; yn=ustep(nn-3)-ustep(nn-8); v=matver; if v < 4, eval('clg');else,eval('clf');end axis([0 12 0 1.5]) dtplot(nn,yn,'o') axis([0 12 0 1.5]) hold off return end if nargin == 1, y=(t>0)+(t==0); elseif nargin == 2, y=(t>0)+a*(t==0); elseif nargin > 2, error('Too many input arguments'); end ………………………………………….. FUNCION URAMP function y=uramp(t) % URAMP Unit Ramp Function. % % Y=URAMP(t) implements the ramp function r(t) = t*u(t) % % URAMP (with no input arguments) invokes the following example: % % % Plot a triangle between -1 and 1 with height 2 % >>t=-3:.05:3; % >>yt=2*[uramp(t+1)-2*uramp(t)+uramp(t-1)]; % >>plot(t,yt),grid % % See Also: UDELTA, URECT, USTEP, TRI if nargin==0, help uramp disp('Strike a key to see results of the example') pause t0=-3:.05:3; yt=2*[uramp(t0+1)-2*uramp(t0)+uramp(t0-1)]; v=matver;

Page 27: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

if v < 4, eval('clg');else,eval('clf');end plot(t0,yt) grid return end if nargin == 1, y=t.*(t>=0); elseif nargin > 1, error('Too many input arguments'); end

suma

Page 28: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

Multiplicación

Seno mas tren pulso

Page 29: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE
Page 30: TRANSFORMACIÓN DE LA VARIABLE INDEPENDIENTE

CONCLUSIONES: Mediante el programa matlab podemos utilizar varias herramientas para graficar impulsos trasformadas y otras

Observamos que las graficas realizadas en matlab son muy parecidas alas que realizamos en el cuaderno

Comprobación de lo aprendido en clase mediante las trasformadas

RECOMENDACIONES

Saber como se utiliusa la herramnienta de matlab para reconocer las señales aprendidas

BIBLIOGRAFIA

Circuitos eléctricos – 7a. ed” de Nilsson, James W., página 286.

Señales y Sistemas - Michael J. Roberts

http://redalyc.uaemex.mx/redalyc/pdf/911/91101309.pdf

http://www.buenastareas.com/ensayos/Desarrollo-De-Una-Aplicacion-En-Matlab/268289.html