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

Write a sequence of Matlab commands that will create a vector (row vector or col

ID: 1716059 • Letter: W

Question

Write a sequence of Matlab commands that will create a vector (row vector or column vector, doesn't matter) containing 800 points such that the first 400 points represent the samples obtained form an analog sinusoidal signal with a frequency of 4 KHz, which has been sampled at Fs = 16 KHz. (Generate the samples such that the first sample has a value of 0). the second 400 points represent the samples obtained form an analog sinusoidal signal with a frequency of 2 KHz, which has ALSO been sampled at Fs = 16 KHz. (Generate the samples such that the first sample in this second half of your overall signal is also 0).

Explanation / Answer

% Sample the sinusoid x = sin(2 pi f t), where f1 = 4 kHz, f2 = 2 kHz.
% Let x1 be the signal sampled at 16 kHz.
% Let x2 be the signal sampled at 16 kHz.

clc;
clear all;
close all;
f1 = 4000;
f2=2000;
T = 1/f1;
tmin = 0;
tmax = 150*T; % Plot 150 cycles
dt = 1/16000; % Sampled at 16kHz
t = tmin:dt:tmax;
x1 = sin(2*pi*f1*t);
x2 = sin(2*pi*f2*t);
subplot(211)
stem(t,x1);
subplot(212)
stem(t,x2);

x1 = x1(1:400); %trim x1 till 400 samples only
x2 = x2(1:400); %trim x2 till 400 samples only

v=[x1,x2]; %concate x1 and x2 into v

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