You are on page 1of 3

Assignment Lab-2

1. ODD and EVEN


t = -1000:0.1:1000;

X = power(t,2) +
power(t,3);
x = fliplr(X);
x_even = 0.5*(x+X);
x_odd = 0.5*(X-x);

subplot(3, 1,1);
plot(t, X);

subplot(3, 1,2);
plot(t, x_even);

subplot(3, 1,3);
plot(t, x_odd);
2. Positive and Negative number

num=input("Enter the number :


\n");
switch(num>0)
case 1
fprintf("%d is a Positive
Number\n", num);
case 0
switch(num<0)
case 1
fprintf("%d is a negative
Number\n", num);
case 0
fprintf("Number is Zero\n");
end
end
3. Operations on Signal
%Time Shifting
%exponential function subplot(3,3,6);
t=-2:0.1:2; stem(t+5,x);
x=exp(t); xlabel("time");
subplot(3,3,1); ylabel("amplitude");
stem(t,x); title("Time Shifted Signal");
xlabel("time");
ylabel("amplitude"); %Addition of two signal
title("Exponential Signal"); ad=x+z;
subplot(3,3,7);
%ramp operations stem(t,ad);
time=-2:0.1:2; title("Added Signal");
unit=t>=0;
z=3*time.*unit; %Subtraction of two signal
subplot(3,3,2); sub=x-z;
plot(time,z); subplot(3,3,8);
hold on; stem(t,sub);
stem(time,z); title("Multiplied Signal");
title("Ramp Signal");
%Multiplication of two signal
%Amplitude Scaling mul=x.*z;
k=3; subplot(3,3,9);
y=3*x; stem(t,mul);
subplot(3,3,3); title("Multiplied Signal");
stem(t,y);
xlabel("time");
ylabel("amplitude");
title("Vertically Scaled
Signal");

%Folding
subplot(3,3,4);
stem(-t,x);
xlabel("time");
ylabel("amplitude");
title("Folded Signal");

%Time Scaling
s=2;
subplot(3,3,5);
stem(s.*t,x);
xlabel("time");
ylabel("amplitude");
title("Time Scaled Signal");

You might also like