Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a variable containing values returned from the sin function at frequency=

ID: 2079907 • Letter: C

Question

Create a variable containing values returned from the sin function at frequency=10Hz and sample rate, Fs=10e3Hz. Run time vector from 0 seconds to 1 second and increment evenly by 1/Fs seconds. The sin command should look like x=sin(2*pi*frequency*time), but with variable names of your choosing.

4a) Paste commands below to create vector with values of sin(2*pi*frequency*time)

4b) Modify 3a to reflect values from the following expression and paste commands below.

( .5*sin(2*pi*frequency*time)*e^-alpha*time ) where alpha=7

4c) Plot sin wave from 3b and paste below.

4d Extra Credit) Figure out a way to find the time of the first three peaks in the sin wave. Paste code and results below. (google “Find Peaks in Data matlab”)

Explanation / Answer

Run the following code int the MATLAB and you will find the plots related to your question.

clc
clear all
close all
%% Given data
fs=10e3;
f=10;
%% Part 4a
t=0:1/fs:(1-(1/fs));
vector=sin(2*pi*f*t);
plot(vector);
title('vector')
ylabel('amplitude')

%% Part 4b
alfa=7;
modified_vector=0.5*vector.*exp(-alfa*t);

%% Part 4c
figure
plot(modified_vector);
title('vector')
ylabel('amplitude')

%% Part 4d
[Peak_amplitude,Location]= findpeaks(modified_vector); %% Peak_amplitude gives the amplitude about all peaks present in the signal
fprintf('first three peaks ')
Peak_amplitude(1:3)
fprintf('Amplitude of first 3 peaks in descending order of height ')
sorted_peaks=sort(Peak_amplitude,'descend'); %% Sorted peaks give the information about all peaks from highest value to lowest value
sorted_peaks(1:3)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote