
C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
expand_more
expand_more
format_list_bulleted
Question
thumb_up100%
Please assist with coding this matlabb problem exercise. Need help with number 1, refer to both image. Thank you.
![1. Exercise 3 shows the non-zero-centered frequency results. Change the code of exercise 3 to display the zero-centered
frequency results and submit the MATLAB programs.
2. The following fft result is too sparse to identify its frequency pattern. Make changes to the code below to get a higher
resolution of frequency (Hint: Exercise 6).
x = [-1, 1, -1, 2]; % original signal in time domain
X = fft(x);
magx = abs(X);
figure (1); subplot (3,1,1); stem (magx);
%% Fill in your code below
% total number of point: 32
subplot (3,1, 2); stem (magX32); axis ([1, 32,0,6])
title('Zero padding: total 32')
% total number of point: 64
subplot (3,1,3); stem (magX64); axis ([1,64,0,6])
title('Zero padding: total 64')
3
1.5
2
2.5
3
3.5
Figure (A): fft result is too sparse to identify its frequency pattern
4](https://content.bartleby.com/qna-images/question/1296c196-158c-4a2c-9587-82b5996e9fed/1a9a9e51-e8eb-4232-9991-80a617b3d492/sbporqh_thumbnail.jpeg)
Transcribed Image Text:1. Exercise 3 shows the non-zero-centered frequency results. Change the code of exercise 3 to display the zero-centered
frequency results and submit the MATLAB programs.
2. The following fft result is too sparse to identify its frequency pattern. Make changes to the code below to get a higher
resolution of frequency (Hint: Exercise 6).
x = [-1, 1, -1, 2]; % original signal in time domain
X = fft(x);
magx = abs(X);
figure (1); subplot (3,1,1); stem (magx);
%% Fill in your code below
% total number of point: 32
subplot (3,1, 2); stem (magX32); axis ([1, 32,0,6])
title('Zero padding: total 32')
% total number of point: 64
subplot (3,1,3); stem (magX64); axis ([1,64,0,6])
title('Zero padding: total 64')
3
1.5
2
2.5
3
3.5
Figure (A): fft result is too sparse to identify its frequency pattern
4
![Exercise 3: Using fft() function, plot the magnitude and phase of the sum of two sine waves.
clear;
close all;
t = 0:1/100:10-1/100;
x = sin(2*pi*15*t) + sin(2*pi*40*t);
figure (1)
plot(t, x)
y = fft(x);
% attention to the number of "y" vector
m = abs(y);
y(m<1e-6) = 8;
plot (f, m)
title('Magnitude')
ax = gca;
ax.XTick = [15 40 60 85];
% Whenever the jump between consecutive angles is greater than or equal to
% π radians, unwrap shifts the angles by adding multiples of ±2π until the
% jump is less than
p= unwrap (angle (y));
f = (0:length (y)-1)*100/length(y);
figure (2)
subplot (2,1,1)
subplot (2,1,2)
plot (f,p*180/pi)
title('Phase')
ax = gca;
ax.XTick= [15 40 60 85];
1.5 H
1
0.5
0
-0.5
-1
-1.5
0
600
400
200
100
50
0
-50
2
-100
15
% Time vector
% Signal
3
15
% Compute DFT of x
Figure (3): Sum of two sine waves in the time domain
% Magnitude
% Phase
% Frequency vector
40
5
40
6
Magnitude
Phase
60
7
60
8
85
9
85
10
Figure (4): Magnitude and phase of the sum of two sine waves](https://content.bartleby.com/qna-images/question/1296c196-158c-4a2c-9587-82b5996e9fed/1a9a9e51-e8eb-4232-9991-80a617b3d492/tob5fem_thumbnail.jpeg)
Transcribed Image Text:Exercise 3: Using fft() function, plot the magnitude and phase of the sum of two sine waves.
clear;
close all;
t = 0:1/100:10-1/100;
x = sin(2*pi*15*t) + sin(2*pi*40*t);
figure (1)
plot(t, x)
y = fft(x);
% attention to the number of "y" vector
m = abs(y);
y(m<1e-6) = 8;
plot (f, m)
title('Magnitude')
ax = gca;
ax.XTick = [15 40 60 85];
% Whenever the jump between consecutive angles is greater than or equal to
% π radians, unwrap shifts the angles by adding multiples of ±2π until the
% jump is less than
p= unwrap (angle (y));
f = (0:length (y)-1)*100/length(y);
figure (2)
subplot (2,1,1)
subplot (2,1,2)
plot (f,p*180/pi)
title('Phase')
ax = gca;
ax.XTick= [15 40 60 85];
1.5 H
1
0.5
0
-0.5
-1
-1.5
0
600
400
200
100
50
0
-50
2
-100
15
% Time vector
% Signal
3
15
% Compute DFT of x
Figure (3): Sum of two sine waves in the time domain
% Magnitude
% Phase
% Frequency vector
40
5
40
6
Magnitude
Phase
60
7
60
8
85
9
85
10
Figure (4): Magnitude and phase of the sum of two sine waves
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 3 steps with 1 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- (Program) Write a program that tests the effectiveness of the rand() library function. Start by initializing 10 counters, such as zerocount, onecount, twocount, and so forth, to 0. Then generate a large number of pseudorandom integers between 0 and 9. Each time 0 occurs, increment zerocount; when 1 occurs, increment onecount; and so on. Finally, display the number of 0s, 1s, 2s, and so on that occurred and the percentage of time they occurred.arrow_forward(Useful utility) Modify the program written for Exercise 3 to search for the first occurrence of a user-entered sequence of characters, and then replace this sequence, when it’s found in the string, with a second user-entered sequence. For example, if the entered string is Figure 4-4 illustrates the output of Program 4-2 and the user enters that 4- is to be replaced by 3-, the resulting string is Figure 3-4 illustrates the output of Program 4-2. (Only the first occurrence of the searched-for sequence has been changed.)arrow_forward(Practice) State whether the following are valid function names and if so, whether they’re mnemonic names that convey some idea of the function’s purpose. If they are invalid names, state why. powerdensity m1234 newamp 1234 abcd total tangent absval computed b34a 34ab volts$ a2B3 while minVal sine $sine cosine speed netdistance sum return stackarrow_forward
- (For thought) a. A token of a computer language is any sequence of characters, with no intervening characters or white space, that taken as a unit has a unique meaning. Using this definition of a token, determine whether escape sequences, function names, and the keywords listed in Table 2.1 are tokens of the C++ language. b. Discuss whether adding white space to a message alters the message and whether messages can be considered tokens of C++. c. Using the definition of a token in Exercise 4a, determine whether the following statement is true: “Except for tokens of the language, C++ ignores all white space.”arrow_forward(Civil eng.) Modify the program written for Exercise 9 to determine the maximum load that can be placed at the end of an 8-foot I-beam, shown in Figure 2.21, so that the stress on the fixed end is 20,000lbs/in2. Use the fact that this beam’s rectangular moment of inertia is 21.4 in4 and the value of c is 3 in.arrow_forward4. Repeat Programming Exercise 3 by declaring numl, num2, and num3, and average of type double. Store 75.35 into numl, -35.56 into num2, and 15.76 into num3.arrow_forward
- (Practice) For the following correct algebraic expressions and corresponding incorrect C++ expressions, find the errors and write corrected C++ expressions: Algebra C++ Expression a.(2)(3)+(4)(5)(2)(3)+(4)(5) b. 6+1826+18/2 c. 4.512.23.1S4.5/12.23.1 d. 4.6(3.0+14.9)4.6(3.0+14.9) e. (12.1+18.9)(15.33.8)(12.1+18.9)(15.33.8)arrow_forward(Heat transfer) The formula developed in Exercise 5 can be used to determine the cooling time, t, caused only by radiation, of each planet in the solar system. For convenience, this formula is repeated here (see Exercise 5 for a definition of each symbol): t=Nk2eAT3fin A=surfaceareaofasphere=4r2 N=numberofatoms=volumeofthespherevolumeofanatom Volume of a sphere sphere=43radius3 The volume of a single atom is approximately 11029m3 . Using this information and the current temperatures and radii listed in the following chart, determine the time it took each planet to cool to its current temperature, caused only by radiation.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrCOMPREHENSIVE MICROSOFT OFFICE 365 EXCEComputer ScienceISBN:9780357392676Author:FREUND, StevenPublisher:CENGAGE LProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- Systems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage LearningC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningOperations Research : Applications and AlgorithmsComputer ScienceISBN:9780534380588Author:Wayne L. WinstonPublisher:Brooks Cole

C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:9780357392676
Author:FREUND, Steven
Publisher:CENGAGE L
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage

Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning

C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning

Operations Research : Applications and Algorithms
Computer Science
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Brooks Cole