(a) Using MATLAB and a sampling frequency of fs=14000 Hz. with a corresponding s
ID: 2079758 • Letter: #
Question
(a)
Using MATLAB and a sampling frequency of fs=14000 Hz. with a corresponding sampling interval of Ts=1/fs, generate a vector of times from 0 3 sec. using the MATLAB command
>> t=0:Ts:3;
Create a signal x1 that is 3 seconds long consisting of a 3000 Hz sinusoid in the interval [0, 1], a chirp going from 3000 to 6000 Hz in the interval [1, 2], and the a 6000 Hz signal in the interval [2, 3].
(b)
Use the MATLAB spectrogram function to plot the time-varying spectrum of the x_1 signal generated in part(a) above.
Explanation / Answer
clc;
close all;
clear all;
Fs = 14000;
Ts = 1/Fs;
t = 0:Ts:3; %sampling window length
SIG = []; %array to concatenate data
for i = 1 : 1 : 3;
if i == 1
tx = 0:Ts:1-Ts;
xt1 = sin(2*pi*3000*tx); %FIRST 1 SECOND
figure(1);
plot(tx,xt1); %EACH INDIVIDUAL PLOT
elseif i == 2
tx= 0:Ts:1-Ts;
fo=3000;f1=6000;
xt1=chirp(tx,fo,1,f1,'q',[],'convex'); %SECOND 1 SECOND
figure(2);
plot(tx,xt1); %EACH INDIVIDUAL PLOT
else
tx = 0:Ts:1;
xt1 = sin(2*pi*6000*tx); %THIRD 1 SECOND
figure(3);
plot(tx,xt1); %EACH INDIVIDUAL PLOT
end
SIG = [SIG,xt1];
end
figure(4);
subplot(2,1,1);
plot(t,SIG); %PLOT OF SIGNAL
title('SIGNAL');
subplot(2,1,2);
[S,F,T] = spectrogram(SIG,200,3,10,14000); %OUTPUT DATA
plot(T,S); %PLOT OF SPECTRUM
title('SPECTRUM');
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.