Using matlab.
Consider the function s(t) defined for t in [0,4) by
{ -sin(pi*t/2)+1 , for t in [0,1)
s(t) = { -(t-2)^5 , for t in [1,3)
{ sin(pi*t/2)-1 , for t in [3,4)
(i) Generate a column vector s consisting of 512 uniform
samples of this function over the interval [0,4). (This
is best done by concatenating three vectors.)
MATLAB code is given below in bold letters.
clc;
close all;
clear all;
% define time t
t = 0:0.01:4;
% now define the signal using logical expressions as
below (concatenation is not required)
s = (-sin(pi*t/2)+1).*(t<=1) +
(-(t-2).^5).*((t>1)&(t<=3)) ...
+ (sin(pi*t/2)-1).*((t>3)&(t<=4));
% now plot the signal as below
figure;
plot(t,s,'linewidth',2);grid
on;xlabel('time');ylabel('Amplitude');title('s(t)');
Get Answers For Free
Most questions answered within 1 hours.