Question

In: Electrical Engineering

Write a matlab code for given task Use your ‘sin’ or ‘cos’ function to generate a...

Write a matlab code for given task

Use your ‘sin’ or ‘cos’ function to generate a sinusoid wave having two components as
f1 = 3kHz and f2 = 5kHz and then sample it with fs = 10kHz. Calculate its fft with zero frequency
component in the middle. Plot it on a properly scaled w-axis. Specify if there is aliasing or not?
If there is aliasing specify which component is casing the aliasing

Solutions

Expert Solution

MATLAB code is given below in bold letters.

clc;
close all;
clear all;


% define f1 and f2
f1 = 3e3;f2 = 5e3;

% define sampling rate
fs = 10e3; % sampling frequency

Ts = 1/fs; % sampling time

t = 0:Ts:1; % time vector

x = sin(2*pi*f1*t) + sin(2*pi*f2*t); % signal x(t) in b


% Finding FFT of x(t)
N = nextpow2(length(x));
X = fftshift(fft(x,2^N));
X = 2* X / length(x);
k = -(length(X)-1)/2:1:length(X)/2;
f = k/length(X) * fs;
figure;plot(f,abs(X));grid;
xlabel('Frequency in Hz');
ylabel('Amplitude');
title('Double sided Magnitude spectrum of x(t) = sin(2*pi*f1*t) + sin(2*pi*f2*t)');

Spectrum is plotted below.

from the above figure, it is observed that the spectrum of the given signal contains only the 3 kHz component and the 5KHz component is not seen. This is because of the fact that the sampling frequency not being sufficient enough to represent both the frequencies. i.e. the component at   3 kHz requires a rate of greater than 6 kHz (satisfied) and the component at 5 kHz that requires greater than 10 kHz ( not satisfied).


Related Solutions

write the MATLAB code for: Let ? = sin2 (?) and ? = sin(?) cos(?). Let...
write the MATLAB code for: Let ? = sin2 (?) and ? = sin(?) cos(?). Let x vary from 0 to 10? in increments of 0.1?. Plot two figures part a & b. This panel has rows, one figure per row. a. Plot x versus y. This plot is on the top of panel and the next figure (part b) is at bottom of panel. i. Give a meaningful title to this figure. ii. x-axis is time with unit of...
This code is to be written in Matlab. Write a function that will plot cos(x) for...
This code is to be written in Matlab. Write a function that will plot cos(x) for x values ranging from -pi to pi in steps of 0.1, using black *'s. It will do this three times across in one Figure Window, with varying line widths. If no arguments are passed to the function, the line widths will be 1, 2, and 3. If on the other hand, an argument is passed to the function, it is multiplier for these values....
Write your own MATLAB code to solve the system 10 − x + sin(x + y)...
Write your own MATLAB code to solve the system 10 − x + sin(x + y) − 1 = 0 8y − cos2 (z − y) − 1 = 0 12z + sin(z) − 1 = 0 using a residual tolerance of 10^−6 and the initial guess, ~x 0 = [0.1, 0.25, 0.08]^T . Print out the values for x, y and z for each iteration in a table similar to the one you created for the problems of the...
Using Matlab, Write a script that validates the relationship between sin u, cos u, and tan...
Using Matlab, Write a script that validates the relationship between sin u, cos u, and tan u by evaluating these functions at suitably chosen values. Please screenshot Matlab screen. Thank you!
Using Matlab, write code to generate Three signal components We will use a sum of sinusoids,...
Using Matlab, write code to generate Three signal components We will use a sum of sinusoids, all of which are sampled at 10 kHz. Signal 1 should contain a sum of sinusoids with frequencies at 25Hz, 40Hz and 75Hz. Signal 2 should contain a sum of sinusoids with frequencies at 600Hz, 730Hz, and 800Hz. Signal 3 should contain a sum of sinusoids with frequencies at 3500Hz, 4000Hz, and 4200Hz. Choose a variety of amplitudes and phase shifts for the sinusoids....
determine whether the given function is even, odd, or neither. Please write a code in MatLab...
determine whether the given function is even, odd, or neither. Please write a code in MatLab to solve this problem below: 1.f(x) = sin 3x please only use Matlab to solve this problem
For the given function determine the following: f (x) = (sin x + cos x) 2...
For the given function determine the following: f (x) = (sin x + cos x) 2 ; [−π,π] a) Find the intervals where f(x) is increasing, and decreasing b) Find the intervals where f(x) is concave up, and concave down c) Find the x-coordinate of all inflection points
Matlab Code Write a procedure to calculate the log discriminant function for a given multi-variate Gaussian...
Matlab Code Write a procedure to calculate the log discriminant function for a given multi-variate Gaussian distribution and prior probability
The language is MATLAB Write a function that will generate three random integers, each in the...
The language is MATLAB Write a function that will generate three random integers, each in the inclusive range from 10 to 80. It will then return a string consisting of the three integers joined together, and also a character vector consisting of the three integers joined together. For example, if the random integers are 11, 29, and 76, the string that is returned will be "112976" and the character vector that is returned will be '112976'. I'm really confused on...
Show that in 2D, the general orthogonal transformation as matrix A given by {{cos, sin}, {-sin,...
Show that in 2D, the general orthogonal transformation as matrix A given by {{cos, sin}, {-sin, cos}}. Verify that det[A] = 1 and that the transpose of A equals its inverse. Let Tij be a tensor in this space. Write down in full the transformation equations for all its components and deduce that Tii is an invariant.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT