Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

FA17-BECE-0009 FAYYAZ KHAN

Lab Exercises:
Question 1:
x=0:0.01:2*pi;
plot(x,sin(x));
xlabel("x-axis");
ylabel("y-axis");
grid on;

Output:

Question 2:
clc;
clear;
close all;
t=0:0.0001:0.01;
a1=1; a2=0.5;
f1=440; f2=880;
x=a1.*cos(2*pi*f1*t);
y=a2.*sin(2*pi*f2*t);
z= x + y;
subplot(2,2,1);plot(t,x);
grid on;
xlabel('Time');
ylabel('Amplitude');
subplot(2,2,2);plot(t,y);
grid on;
xlabel('Time');
ylabel('Amplitude');
subplot(2,2,3);plot(t,z);
grid on;
xlabel('Time');
ylabel('Amplitude');
FA17-BECE-0009 FAYYAZ KHAN

Output:

Question 3:
clc;
clear;
fs= 100;
t=0:(1/fs):(10-1/fs);
s=cos(2*pi*15*t);
n=length(s);
x=fft(s);
f=(0:n-1)*(fs/n);
power=abs(x).^2/n;
plot(f,power);
xlabel('Time');
ylabel('Power');

Output:
FA17-BECE-0009 FAYYAZ KHAN

Question 4:
x = sin(t);
plot(t,x,'LineWidth',2);grid on;hold on
x1 = 2.*x;
plot(t,x1,'r','LineWidth',2);hold on;
x2 = 0.5.*x;
plot(t,x2,'g','LineWidth',2);hold on;
x3 = sin(2.*t);
plot(t,x3,'m','LineWidth',2);hold on;
x4 = sin(0.5.*t);
plot(t,x4,'y','LineWidth',2);hold on;
x5 = sin(2+t);
plot(t,x5,'c','LineWidth',2);hold on;
x6 = sin(t-2);
plot(t,x6,'black','LineWidth',2);hold on;
legend('Original','Y axis Stretch','Y axis Compress','X axis Stretch','X
axis,Stretch','Signal advancement','Signal delay')

Output:

You might also like