Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

PROCESAMIENTO DE SEÑALES

LABORATORIO II
INTEGRANTES:
DANIEL FELIPE NEUTA - 2016119065
GABRIEL ENRIQUE ANAYA - 2016219084
JESUS GABRIEL MAIGUEL – 2016119052

EJEMPLO B. BUSCAR PERIODICIDAD MEDIANTE AUTOCORRELACIÓN


scrip:

%Ejemplo B. Buscar periodicidad mediante autocorrelación


load officetemp
tempC = (temp-32)*5/9;
tempnorm = tempC-mean(tempC);
fs = 2*24;
t = (0:length(tempnorm) - 1)/fs;
plot(t,tempnorm)
xlabel('Tiempo (Dias)')
ylabel('Temperatura ( {}^\circC )')
axis tight
[autocor,lags] = xcorr(tempnorm,3*7*fs,'coeff');
plot(lags/fs,autocor)
xlabel('Retrazo (Dias)')
ylabel('Autocorrelación')
axis([-21 21 -0.4 1.1])
[pksh,lcsh] = findpeaks(autocor);
short = mean(diff(lcsh))/fs
[pklg,lclg]=findpeaks(autocor,'MinPeakDistance',ceil(short)*fs,'MinPeakheight',0.3);
long = mean(diff(lclg))/fs
hold on pks = plot(lags(lcsh)/fs,pksh,'or',lags(lclg)/fs,pklg+0.05,'vk');
hold off legend(pks,[repmat('Period: ',[2 1]) num2str([short,long],0)])
axis([-21 21 -0.4 1.1])

hold on pks = plot(lags(lcsh)/fs,pksh,'or',lags(lclg)/fs,pklg+0.05,'vk');


hold off legend(pks,[repmat('Period: ',[2 1]) num2str([short;long],0)])
axis([-21 21 -0.4 1.1])

EJEMPLO C. BUSCAR PERIODICIDAD MEDIANTE EL ANALISIS DE FRECUENCIA


Scrip:

% Ejemplo C. Buscar periodicidad mediante el analisis de frecuencia


load officetemp
tempC = (temp - 32)*5/9;
fs = 2*24*7;
t = (0:length(tempC) - 1)/fs;
plot(t,tempC)
xlabel('Tiempo (Semanas)')
ylabel('Temperatura ( {}^\circC )')
axis tight
tempnorm = tempC - mean(tempC);
[pxx,f] = periodogram(tempnorm,[],[],fs);
plot(f,pxx)
ax = gca;
ax.XLim = [0 10];
xlabel('Frecuencia (ciclos/semanas)')
ylabel('Magnitud')

EJEMPO D. PROCESAR UNA SEÑAL CON MUESTRAS QUE FALTAN

Scrip:

% Ejemplo D. Procesar una señal con muestras que faltan


load (fullfile(matlabroot,'examples','signal','weight2012.data'))
wgt = weight2012(:,2)/2.20462;
daynum = 1:length(wgt); missing = isnan(wgt);
fprintf('Missing %d samples of %d\n',sum(missing),max(daynum))
wgt_orig = wgt;
wgt = resample(wgt,daynum);
plot(daynum,wgt_orig,'.-',daynum,wgt,'o')
xlabel('Day')
ylabel('Weight (kg)')
axis([200 250 73 77])
legend('Original','Interpolated')
grid
Fs = 7;
[p,f] = pwelch(wgt-mean(wgt),[],[],[],Fs);
plot(f,p)
xlabel('Frequency (week^{-1})')
grid
wgd = reshape(wgt(1:7*52),[7 52]);
plot(wgd')
xlabel('Week')
ylabel('Weight (kg)')
q = legend(datestr(datenum(2012,1,1:7),'dddd'));
q.Location = 'NorthWest';
grid
wgs = sgolayfilt(wgd',3,7);
plot(wgs)
xlabel('Week')
ylabel('Weight (kg)')
title('Smoothed Weight Fluctuations')
q = legend(datestr(datenum(2012,1,1:7),'dddd'));
q.Location = 'SouthEast';
grid
EJEMPLO E. GENERACION DE GRAFICAS
Scrip:

%generacion de graficas
f=100; %ingreso de la frecuencia
A=5; %amplitud de la onda
d=1 %duacion de la grafica
Fmax=f; %frecuencia maxima
Fs=20*Fmax; % Frecuencia de muestreo
Ts=1/Fs; % inverso de la frecuencia de muestreo
t=0:Ts:d; % vector de tiempo

x=A*sin (2*pi*f*t); %funcion 1


y=((3/4)*x)+x.^2; % funcion 2

%graficas
subplot (2,2,1) % para dividir las graficas
plot(t,x,'r') % comando que grafica la funcion
title ('grafica de x(t) en el dominio del tiempo'); % titulo de la grafica
xlabel('tiempo'); % titulo del eje x
ylabel('amplitud'); %titulo del eje y

subplot(2,2,2)
plot (t,y,'r')
title ('grafica de y(t) en el dominio del tiempo');
xlabel('tiempo');
ylabel('amplitud');

%funcion 1 dominio de la frecuencia


L=length(x);%Dimencion de la funcion x
nFFT=2; % funcion de la transformada de fourier
while nFFT<L
nFFT=nFFT*32;
end
Y1=fft(x,nFFT); %funcion de la transformada de fourier
PS1=abs(Y1); %periograma simple
f=linspace(0,Fs,nFFT); % Vector de tiempos
subplot(2,2,3)
plot(f,PS1)
axis ([0 Fs/2 0 max(PS1)]) % para definir el inicio y fin de los ejes
title('grafica x(t) dominio de la frecuencia')
xlabel('frecuencia (Hz)')
ylabel('amplitud')
%funcion 2 domino de la frecuencia
Y2=fft(y,nFFT);
PS2=abs (Y2); %periodograma simple
f=linspace (0,Fs,nFFT);
subplot(2,2,4)
plot(f,PS2)
axis([0 Fs/2 0 max(PS2)])
title('grafica y(t) dominio de la frecuencia')
xlabel('frecuencia (Hz)')
ylabel('amplitud')

You might also like