Using Matlab, calculate the coefficients X[k] with a = 0.4 Note that the coeffic
ID: 2081589 • Letter: U
Question
Using Matlab, calculate the coefficients X[k] with a = 0.4 Note that the coefficients X[k] are complex numbers. On separate axes, plot the magnitude and phases of for values of X[k] for values k = 1, 2, ..., 10. Include these plots in your report. Write a function. SqWave which generates a square wave of specified dutycycle. total time for which the wave is generated, and sampling frequency. The function should have the following inputs and outputs: Inputs: Duty-cycle Total time for which the square wave is defined Sampling Frequency Outputs: Square Wave use the Matlab function square to accomplish this task. Use the SqWave function to generate a unit amplitude. 440 Hz square-wave, a = 0.1, 0.2, ... 0.5, that lasts for 2 s. Use a sampling frequency of 44.1 kHz. Play back the tone over your speakers using the sound command. How does the perceived tone change as you vary a? Next, we will approximate the square wave with a sum of complex sinusoids. Note that the Fourier series involves the summation of an infinite number of sinusoids. We will only employ a limited set of sinusoids, so we will refer to this as a truncated Fourier series. Write a function SqWaveFromFS that computes an approximate square wave using the truncated Fourier Series. It should take the same inputs as SqWave. as well as an additional input K. which refers to the number of sinusoids considered in the truncated series The value of the square wave's amplitude at time t. is obtained by summing up a number of terms. As such, it may seem appropriate to use loops to implement this in Matlab. Your code will run very slowly if you use loops Look up the Matlab function meshgrid and consider how you might take advantage of it to implement your Fourier Series calculations without using loops. Compare the square wave generated with SqWave and that generated using the SqWaveFromFS. In your report, include a plot of the first 5 cycles of the square wave and the approximated square wave on the same axes. Use different Iinestyles or colors so that the two curves can be easily distinguished. What are the differences between these two signals? Explain the reasons for any differences m your report.Explanation / Answer
3) Code for sampling and gettting the sqaure wave of duty cycle
clc
close all;
clear all;
x=input('amplitude=');
z= input('Frequency= ');
duc=input('Duty Cycle= ');
z=z*2*pi;
t=0:.001:1;
p=x*square(z*t,duc);
plot(t,p);
axis([0 1 -3 3]);
title('Generation of Square Wave of Duty Cycle')
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.