In: Computer Science
In Matlab please part b and c
1. Generate a 1000 Hz sinusoid time sequence for 6 cycles with sampling frequency 20 kHz. Note: A sine wave with frequency fc is given by sin(2πfct). (a) Use the ‘plot’ command to display the result. (b) How many samples are present in one period of the sine wave? (c) What is the total length of the time and amplitude vectors here?
I got part a:
clear all;
clc;
f_s= 16000;
f=1000;
cycleCount =4;
time = 0: 1/f_s : cycleCount*(1/f);
signlA = sin(2*pi*f*time);
figure (1);
plot(time,signlA);
title ('Task 1');
xlabel ('Time Vector');
ylabel ('amplitude');
Solution for the problem is provided below:
Note: Your given answer of part a has some value errors, it is not according to the question given, I corrected it according to the question, if the correction is not needed, just use the original code, but it is not the part a answer.
Changes made:
F_s = 20000, you gave it as 16000
Cycle count = 6, you gave it as 4
The updated code and part b and part c are included in the below code:
close all;
clear all;
clc;
f_s= 16000;
f=1000;
cycleCount =6;
time = 0: 1/f_s : cycleCount*(1/f);
signlA = sin(2*pi*f*time);
figure (1);
plot(time,signlA);
title ('Task 1');
xlabel ('Timea Vector');
ylabel ('amplitude');
%%%part b
%samples in one period of wave
NumberofSamplesPerPeriod=length(time)/cycleCount
%%%part c
%total length of time vector
Total_length_of_time_vector=length(time)
%total length of amplitude vector
Total_length_of_amplitude_vector=length(signlA)
Output: