Você está na página 1de 24

UNIVERSIDAD POLITÉCNICA

SALESIANA

SEDE QUITO – CAMPUS KENNEDY

FACULTAD DE INGENIERIAS

CARRERA DE INGENIERÍA ELÉCTRICA

TRANSFORMACION DE LA VARIABLE
INDEPENDIENTE

AUTOR: WILLIAM AGUIRRE

QUITO, 10 DE JULIO DEL 2010


Práctica 2

Transformación de la variable independiente

Objetivo: Entender mediante el uso del matlab las distintas propiedades de las señales
al realizar transformación de la variable independiente.

1. 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.

 Función escalamiento

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

2. 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)

t=-5:0.001:5
x= stepcont(-2,-5,5)
[x1,t1]= sigshift(x,t,-2)
plot(t1,x1)
b. Señal x(t+2)

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

t=-5:0.001:5
x= stepcont(-2,-5,5)
[x1,t1]= sigfold(x,t)
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)
3. 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
4. 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
x= stepcont(-2,-5,5)
[x1,t1]= sigfoldi(x,t)
plot(t1,x1)
grid on

5. 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)

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)

n=-5:1:5
x= stepseq(-2,-5,5)
[x1,n1]= escale(x,n,2)
stem(n1,x1)
6. 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)

Para señales discretas se puede utilizar la función sigadd


7. Realizar las transformaciones en el tiempo de todos los ejercicios y pruebas
realizados en clase
8. 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

DETERMINACION DE LA RESPUESTA NATURAL DE UN CIRCUITO RC

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

a. 𝑉𝑐 𝑡 𝑝𝑎𝑟𝑎 𝑡 ≥ 0 ;
b. 𝑉𝑜 𝑡 𝑝𝑎𝑟𝑎 𝑡 ≥ 0+;
c. 𝑖𝑜 𝑡 𝑝𝑎𝑟𝑎 𝑡 ≥ 0+
d. La energía total disipada en la resistencia de 60kΩ
SOLUCION

a. Puesto que el conmutador ha estado en la posición x durante un largo


periodo de tiempo, el condensador de 0,5μF se cargara hasta 100V,
siendo la tensión positiva en el terminal superior. Podemos sustituir la
red resistiva conectada al condensador en 𝑡 = 0+ por una resistencia
equivalente de 80kΩ.Asi, la constante de tiempo del circuito es
0,5𝑥10−6 (80𝑥103 ) o 40 ms. Entonces

Vc(t) = 100e−25t V,𝑡≥0


b. La forma mas fácil de calcular Vo(t) es observar que el circuito resistivo
forma un divisor de tensión entre los terminales del condensador. Por
tanto,
48
𝑉𝑜 = 80 𝑉𝑐 𝑡 = 60𝑒 −25𝑡 𝑉,𝑡 ≥ 0+

Esta ecuación es válida para 𝑡 ≥ 0+ porque 𝑉𝑜(0−) es cero. Es decir, tenemos un


cambio instantáneo de tensión entre los terminales de la resistencia de 240kΩ.
𝑉𝑜 (𝑡) −25𝑡
c. Calculamos la corriente 𝑖𝑜 𝑡 = 60𝑥10 3 = 𝑒
𝑚𝐴, 𝑡 ≥ 0+
d. La potencia disipada en la resistencia de 60kΩ sera

𝑃60𝑘Ω 𝑡 = 𝑖02 𝑡 60𝑥103 = 60𝑒 −25𝑡 𝑚𝑊, 𝑡 ≥ 0+

La energía disipada es

𝑊60𝑘Ω = 𝑖𝑜2 𝑡 60𝑥103 𝑑𝑡 = 1,2𝑚𝐽


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

% Corriente de salida 𝑖𝑜 (t) = e−25t


% B= amplitud
% a= valor del exponente
% tiempo
B=60;
a=25;
t=0:0.001:1;
x=B*exp(-a*t);
plot(t,x)
9. 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)

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

10. 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)
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));
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');
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.


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

Vamos a sumar y multiplicar dos funciones un tren de pulsos y una rampa.

SUMA

MULTIPLICACION
SENO MAS TREN PULSO

SUMA
MULTIPLICACION

CONCLUSIONES

1. Con matlab se puede dar solución a circuitos RC .


2. Existen diferentes programas como el que se usa en esta práctica para realizar
operaciones de señales dando una solución de una manera rápida y precisa.

BIBLIOGRAFIA.

1. Señales y Sistemas - Michael J. Roberts


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

Você também pode gostar