0% found this document useful (0 votes)
16 views2 pages

PART1

This document defines two functions, x(t) and h(t), that return 1.0 when the input is greater than or equal to 0 and otherwise. It then convolves the two functions to produce a new output function y(t). Finally, it plots the original functions and the output convolution on a figure with three subplots to visualize the process.

Uploaded by

amin badrul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

PART1

This document defines two functions, x(t) and h(t), that return 1.0 when the input is greater than or equal to 0 and otherwise. It then convolves the two functions to produce a new output function y(t). Finally, it plots the original functions and the output convolution on a figure with three subplots to visualize the process.

Uploaded by

amin badrul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Badrul Amin bin Zambri 212759

PART 1

% close all other command and clear all variables from matlab workspace
close all
clear
clc

% defines a function x(t) and h(t) and the both function will return value 1.0 when the inout
is greater than or equal to 0 and otherwise.
x=@(t) 1.0*(t>=0).*exp(-t);
h=@(t) 1.0*(t>=0).*exp(-2*t);

%Set a step size


delta=0.01;
%generates a range of time values for x(t) and h(t) which range is form -10 to 10
tx=-10:delta:10;
th=-10:delta:10;

%convolves the two functions x(t) and h(t)


y=conv(x(tx),h(th))*delta;
% generates a range of time values for y(t) based on the time ranges for x(t) and h(t)
ty=(tx(1)+th(1)):delta:(tx(end)+th(end));

%Create figure for plotting and the title


figure()
title('output y')
% Plot input signal of x(t).
subplot(3,1,1)
plot(tx,x(tx))
xlabel('n'); title('x(t)'); ylim([min(x(tx))-1,max(x(tx))+1]); grid on
% Plot impulse response of h(t)
subplot(3,1,2)
plot(th,h(th))
xlabel('n'); title('h(t)'); ylim([min(h(th))-1,max(h(th))+1]); grid on
% Plot the output signal of y
subplot(3,1,3)
plot(ty,y);
xlabel('n'); title('x(t)*h(t)');ylim([min(y)-1,max(y)+1]); grid on

You might also like