Question

In: Electrical Engineering

In this part of the assignment, you will need to calculate the cross-correlation of two random...

In this part of the assignment, you will need to calculate the cross-correlation of two random signals. In the Appendix: Part II, we include the function ccorr that gives you the crosscorrelation of two input vectors.

MATLAB provides other built-in function that may be useful for this part of the assignment

• max: gives you the maximum value of a vector. For more information type help max

find: gives you the index corresponding to a value of a vector. For more information type help find.

Finally, you will also need to use a linear filter in Exercise 3. You can use the function linfilt that you already used in MA2.

You can calculate the cross-correlation between two random signals in MATLAB by using the function ccorr given in the Appendix: Part II. As an example, consider two random signals x(t) and y(t), which are both modeled as white Gaussian random processes with mean 0 and variance 1. We plot the cross-correlation function Rxy(? ) of the random signals x(t), y(t) by applying the following MATLAB code:

t = -10:0.01:9.99;

x = randn(1, length(t));

y = randn(1, length(t));

[cc, tau] = ccorr(x,y,t);

plot(tau,cc);

In the same way you can plot the autocorrelation of signal x(t) [ac, tau] = ccorr(x,x,t); plot(tau, ac);

Now assume that y(t) is the output of a linear filter with impulse response h(t) = |sinc(t ? 2)|

where the input x(t) is a white Gaussian random signal with mean 0 and variance 1. Create an M-file to:

(a) Calculate y(t) using the function linfilt and plot x(t) and y(t) where t ranges from ?10 to 9.99, using 0.01 increments. NOTE: y(t) is the output signal of the filter, so if N is the length of the vector t, the length of y(t) is N + N ? 1 (convolution of two functions with length N). You will have to find the indices that correspond to t from ?10 to 9.99.

(b) Plot the cross-correlation function Rxy(? ).

(c) Plot the autocorrelations Rxx(? ) and Ryy(? ) of x(t) and y(t), respectively.

Solutions

Expert Solution

clc
clear all
close all
t=-10:0.01:9.99;
x=1*randn(1,length(t))+0; %input;
h=sinc(t-2); %filter
y=linfilt(x,h,length(t)); %function
subplot(211)
plot(t,h)
title('Input random signal')
xlabel('time')
ylabel('Amplitude')
subplot(212)
%plot(y)
t1=-20:0.01:19.98;
plot(t1,y)
title('Convoluted output')
xlabel('time')
ylabel('Amplitude')
axis([-10 9.99 min(y)-1 max(y)+1])
%Cross correlation
[C tau]=xcorr(x,y);
figure;
plot(tau,C)
title('Cross Correlation of x(t) & y(t)')
[A1 tau]=xcorr(x,x);
figure;
plot(tau,A1)
title('Auto Correlation of x(t)')
[A2 tau]=xcorr(y,y);
figure;
plot(tau,A2)
title('Auto Correlation of y(t)')

%linear filter function

function y=linfilt(x,h,t)
y=conv(x,h);

Output:

There is no ccorr function in matlab,instead we have xcorr to perform auto correlation and cross correlation.So I used those. If you are not intended to use this inbuilt function but only use user defined function of ccorr then let me know so that I can rewrite the code and submit.

h(t)=sinc(t-2) is what I have taken. linfilt function isjust convolution between input x(t) and filter h(t).

After convolution the time stampwill be from -20 to 19.98. In that we have to plot only for -10 to 9.99. So used axis command to display given specified range.

Please leave feedback for my improvement.

Thankyou.


Related Solutions

you must calculate the deviations from the average, the manual correlation calculation and cross check it...
you must calculate the deviations from the average, the manual correlation calculation and cross check it with Excel's correl function. Furthermore, you will generate the scatterplot graph, along with the trendline. Indicate whether there is a strong/weak/no correlation between the two variables. Question: The following tables shows the mpg and curbed weight, in thousands for eight randomly selected vehicles: MPG:                    28           22           20           34           41           15           19           15 Weight:                2730       2860       3140       2180       2310       4450       3920       2590 Using XLS, calculate...
you must calculate the deviations from the average, the manual correlation calculation and cross check it...
you must calculate the deviations from the average, the manual correlation calculation and cross check it with Excel's correl function. Furthermore, you will generate the scatterplot graph, along with the trendline. Indicate whether there is a strong/weak/no correlation between the two variables. Question: The Swiss Hiking Federation is an organization that is known for promoting the same use of the hiking trail system throughout Switzerland. Suppose SHF would like to investigate the linear relationship between the amount of time to...
you must calculate the deviations from the average, the manual correlation calculation and cross check it...
you must calculate the deviations from the average, the manual correlation calculation and cross check it with Excel's correl function. Furthermore, you will generate the scatterplot graph, along with the trendline. Indicate whether there is a strong/weak/no correlation between the two variables. Question: The following tables shows the selling prices, in thousands of dollars, and the square footages of seven randomly selected homes recently sold by Century 21 Realtors: Price:     258         191         253         168         249         245         282 Sqr Ft:   2730      ...
I need an example of how to calculate correlation in excel
I need an example of how to calculate correlation in excel
You are running correlation analysis on a data set with 11 items. You calculate the correlation...
You are running correlation analysis on a data set with 11 items. You calculate the correlation coefficient to be 0.845. What is the critical value?
IA 2 is a two-part assignment. The first part requires you to identify, by statute number,...
IA 2 is a two-part assignment. The first part requires you to identify, by statute number, and summarize the statute that prohibits telephone solicitors from blocking or interfering with a residential telephone subscriber's caller ID function.
Please answer this two part question. Thank you! For this assignment you must write the following...
Please answer this two part question. Thank you! For this assignment you must write the following functions in Scheme: 2.1 Write a recursive function called eval-poly that takes a list of numbers representing the coefficients of a polynomial and a value for ? and evaluates the polynomial for the given value of ?. The list of coefficients should start with the term of lowest degree and end with the term of highest degree. If any term of intermediate degree is...
Assignment Specifications Task Criteria: There are two parts to this assignment. Part 1 – Analysis of...
Assignment Specifications Task Criteria: There are two parts to this assignment. Part 1 – Analysis of Mini Case (must demonstrate understanding of the theories or concepts in the case and their applications. Part 2 – Critical Thinking. Must demonstrate critical thinking skills to develop a valid discussion and with supporting evidence to your chosen product and target markets. Details of task requirements: Part 1: Mini Case (video) Analysis of Market Segmentation, watch “Grilled Burger” ad and answer 2 questions below....
If you calculate a correlation of .954 can you say that the variable is a cause...
If you calculate a correlation of .954 can you say that the variable is a cause of the change in the other variable?
Assume that it is appropriate and meaningful to calculate the correlation coefficient of two variables X...
Assume that it is appropriate and meaningful to calculate the correlation coefficient of two variables X and Y. If the correlation coefficient, r, has a value -0.95 Select one: a. it is impossible to tell if there is a linearly relationship between the two variables b. there is a strong linear relationship between the two variables c. there is no relationship between the two variables d. the slope of the regression line will be -0.95 2. The father's height (in...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT