0% found this document useful (0 votes)
32 views2 pages

1, Cross Correlation: 2, To Perform Discrete-Time Exponential Harmonics

This document contains code to perform two tasks: 1) Cross correlation of two discrete sequences to find the correlation between them. It inputs two sequences, calculates their cross correlation and plots the input, output and correlation. 2) Calculate and plot the real and imaginary parts of discrete-time exponential harmonics up to the third harmonic to understand their behavior in the time domain. It generates the real and imaginary parts of the first three harmonics and plots them on the same axes for comparison.

Uploaded by

Md Rabiul Awal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views2 pages

1, Cross Correlation: 2, To Perform Discrete-Time Exponential Harmonics

This document contains code to perform two tasks: 1) Cross correlation of two discrete sequences to find the correlation between them. It inputs two sequences, calculates their cross correlation and plots the input, output and correlation. 2) Calculate and plot the real and imaginary parts of discrete-time exponential harmonics up to the third harmonic to understand their behavior in the time domain. It generates the real and imaginary parts of the first three harmonics and plots them on the same axes for comparison.

Uploaded by

Md Rabiul Awal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1, Cross correlation 2, To perform discrete-time

Exponential Harmonics
clc; clc;
clear all; clear all;
close all; close all;
x=input(' Enter The sequence 1: '); N=3;
h=input(' Enter The sequence 2: '); w=2*pi/N;
y=xcorr(x,h); fs=500; % Real time sample rate
figure; (hz)
subplot(3,1,1); t=-3:1/fs:3; % Time index (s)
stem(x); n= -3:1:3; %sample index
xlabel('n--->'); for cnt = 1:4;
ylabel('Amplitude--->'); subplot(4,2,cnt*2-1);
title('Input Sequence 1');
h=plot(t,real(exp(j*cnt*w*t)),'r');
subplot(3,1,2); set(h,'Linewidth',1);
stem(h); hold on;
xlabel('n--->');
ylabel('Amplitude--->'); h=stem(n,real(exp(j*cnt*w*n)),'.');
title('Input Sequence 2'); hold off;
box off;
subplot(3,1,3); grid on;
stem(fliplr(y)); xlim([min(t) max(t)]);
xlabel('n--->'); ylim([-1.1 1.1]);
ylabel('Amplitude--->'); ylabel(sprintf('\\phi_%d',cnt));
title('Output Sequence'); subplot(4,2,cnt*2);
disp(' The resultant is: ');
fliplr(y) %% Row flip h=plot(t,imag(exp(j*cnt*w*t)),'r');
set(h,'Linewidth',1);
r=corrcoef(y) hold on;

h=stem(n,imag(exp(j*cnt*w*n)),'g');
hold off;
box off;
grid on;
xlim([min(t) max(t)]);
ylim([-1.1 1.1]);
ylabel(sprintf('\\phi_%d',cnt));

end;

Fig 1: Correlation of two input sequence

You might also like