Académique Documents
Professionnel Documents
Culture Documents
Objective
To generate programs on MATLAB to find the even and odd plots, and to shift and scale the
given discrete and continuous plots.
Mathematical Functions
()+()
1. Even Function: y(t) = 2
()()
2. Odd Function: y(t) = 2
Code
1. To generate Even and Odd Plots for a User Defined Discrete Plot.
Also Shift and Scale the Plot.
clc;
clear all;
close all;
a = input ('Enter the range of a: ')
x=(-a:a);
for i=1:length(y)
y2(i)=y(((length(y)+1)-i))
end
subplot (3,3,2)
stem (x,y2)
title ('Invert Plot')
grid on
for i=1:length(y)
y3(i)=((y(i)+y2(i))/2)
end
subplot (3,3,3)
stem (x,y3)
title ('Even Plot')
grid on
for i=1:length(y)
y4(i)=((y(i)-y2(i))/2)
end
subplot (3,3,4)
Monday, January 23, 2017 Page |
Experiment 2: Generating Even, Odd, Shifting and Scaling Plots BT15ECE022
stem (x,y4)
title ('Odd Plot')
grid on
for i=1:length(x)
if x(i)>=-2 && x(i)<=-1
y(i)=x(i)+1
else if x(i)>-1 && x(i)<=0
y(i)=1
else if x(i)>0 && x(i)<=1
y(i)=2
else if x(i)>1 && x(i)<2
y(i)=1
else
y(i)=0
end
end
end
end
end
subplot(3,3,1)
plot(x,y)
title('Original Plot')
grid on
for i=1:length(y)
y2(i)=y(((length(y)+1)-i))
end
Monday, January 23, 2017 Page |
Experiment 2: Generating Even, Odd, Shifting and Scaling Plots BT15ECE022
subplot(3,3,2)
plot(x,y2)
title('Invert Plot')
grid on
for i=1:length(y)
y3(i)=((y(i)+y2(i))/2)
end
subplot(3,3,3)
plot(x,y3)
title('Even Plot')
grid on
for i=1:length(y)
y4(i)=((y(i)-y2(i))/2)
end
subplot(3,3,4)
plot(x,y4)
title('Odd Plot')
grid on
Input
1. To generate Even and Odd Plots for a User Defined Discrete Plot.
Also Shift and Scale the Plot.
Enter the value of a as 2.
Enter the values of y as [-1,1,2,1,0].
Enter the value by which the plot is to be shifted as 5.
Enter the value by which the plot is to be scaled as 5.
Output
1. To generate Even and Odd Plots for a User Defined Discrete Plot.
Also Shift and Scale the Plot.
Result
Monday, January 23, 2017 Page |
Experiment 2: Generating Even, Odd, Shifting and Scaling Plots BT15ECE022
MATLAB programs have been generated for creating a user defined discrete plot and continuous
plot. The even and odd plots have been generated and also the plots have been shifted and scaled.