Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Write a MATLAB code that creates two cosine signals, namely x1 = A1*cos(2*pi*

ID: 2291992 • Letter: 1

Question

1. Write a MATLAB code that creates two cosine signals, namely x1 = A1*cos(2*pi*f1*1:NI); and x2 A2*cos(2*pi*f2*[1:N2]); where: the magnitudes A1 and A2 are random numbers between 1 and 2 the frequencies f1 and f2 are random numbers between 0.2 and 0.4 the lengths (or duration) of the cosine, N1 and N2, are random numbers between 100 and 300. Then, concatenate the two signals to form a single signal x = [x1 x2]; Make sure that x1 and x2 are both row vectors. Otherwise, this is not going to work, because x has to be a row vector of length equal to sum of lengths of x1 and x2. 3. Write a MATLAB code using a loop that splits signal x in non-overlapping segments of length 50. Place each segment in a MATLAB cell. For each segment, sf1}, sí21, etc, use the FFT magnitude (abs(fft(slij)) for the i-th segment) to find the location of the maximum peak. You can use find for this purpose. For example, if F = abs(fft(s(i))), then w = find(F == max(F): will return a vector w containing the location of the peaks. Remember that the FFT magnitude will contain peaks symmetrically located around the center. Thus, you need to keep only the first location, i.e., w(1) Using w(1), determine the frequency of the cosine in segment s(i]. 4. Use Simulink to create a sinewave of a frequency of your choice, and add the constant value 2 to it. Show both original sinewave and the sinewave with the 2 added in a scope.

Explanation / Answer

Answer :1)

clc;
clear all;
close all;

N1=randint(1,1,[100 300]);
N2=N1;
a1=1;
b1=2;
A1=(b1-a1).*rand(N1,1)+a1;


e1=0.2;
f1=0.4;
F1=(f1-e1).*rand(N1,1)+e1;

a2=1;
b2=2;
A2=(b2-a2).*rand(N2,1)+a2;

e2=0.2;
f2=0.4;
F2=(f2-e2).*rand(N2,1)+e2;

x1=(A1')*cos(2*pi*F1*[1:N1]);
x2=(A2')*cos(2*pi*F2*[1:N2]);

x=[x1 x2]

....................................................................................................

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote