Create a new script. Name it lastname_firstname_prob_1. Create the template for
ID: 2082336 • Letter: C
Question
Create a new script. Name it lastname_firstname_prob_1. Create the template for this script as shown on p. 2. Observe file naming convention. Load the Matlab file 'Handel.mat' as you did in Midterm 2. Set the sampling interval dt as the inverse of Fs. Create a time vector t that is the same length as/(Midterm 2). Use Fs. Transpose the time vector t just created so it is the same size as y (check Workspace). Use subplot to setup space for three rows and one column of plots. Plot t and y on the first subplot. Create xlabel, ylabel and title as shown in the figure below. Next you will do a frequency analysis of y using the function pwelch. Specify the second subplot location before you execute pwelch. This will automatically create a plot (subplot 2 in figure shown). Make sure you create the necessary number of placeholders in pwelch. Save the axis parameters into the variable now for later use. Note that the units of the frequency axis are kHz. Specify the third suplot location for the next execution of pwelch. This time use the first two values in now to limit the frequency axis to 2 kHz starting from 0. I.e. use the values you saved in now but replace the second value with 2 inside the function axis. AFTER the axis command in step 11, a. Within your script after axis, set maxValue = ginput. b. The script will stop running waiting for your response in subplot three. c. Use the resulting cross-hairs to point to and click on the largest peak you observe on subplot three. d. Press Enter. You should see a pair of numbers. The first number is the frequency of the peak (kHz); the second number is the relative amplitude of the peak. Setup a text line like we've done before for the peak you have identified. Use num2str for the first value in maxValue. Complete the rest of the text statement to match what is shown in the figure below. Place the text statement at the normalized height of 0.90. For the text horizontal position, use 0.05 (normalized). Your final plot should look like the one below. Your maxValue numbers will probably be different than shown.Explanation / Answer
thank you for choosing chegg!!
load('Handel.mat');
dt=Fs^-1;
x=size(y);
x=(x-1)*dt;
t=0:dt:x;
t=t';
subplot(3,1,1);
plot(t,y);
xlabel(' your label here ');
ylabel(' y ');
subplot(3,1,2);
pwelch(y);
subplot(3,1,3);
pwelch(y,2);
maxValue=ginput
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.