Vous êtes sur la page 1sur 9

# Assignment:-Scilab 11-01-14 RCID 1222

I. Best assignments
1. C.A. Patil
2. Shweta Jain

## // Participant - C A Patil, Shweta Jain

//Sample the signal x(t)=cos(2*%pi*50*t)+cos(2*%pi*100*t) using sampling
frequency f = 250 Hertz. Obtain sample over the interval0 to 0.2 second.
clear;
clc ;
close ;
t=0:0.0001:0.2;
x1=cos(2*%pi*50*t)+cos(2*%pi*100*t);
subplot(1,2,1);
plot(t,x1);
xlabel('t');
ylabel('x(t)');
title('CONTINUOUS TIME PLOT');
n=0:0.004:0.2;
x2=cos(2*%pi*50*n)+cos(2*%pi*100*n);
subplot(1,2,2);
plot2d3(n,x2);
xlabel('n');
ylabel('x(n)');
title('DISCRETE TIME PLOT');

## // Participant - C A Patil, Shweta Jain

//Example- x(t)=cos(2*pi*50t)+cos(2*pi*100t)

clc;clear;close;
A=1;T=2;
w0=2*%pi*100/T;

## //Calculation of trignometric fourier series co-efficients

a0=A/T*integrate('cos(w0*t)+cos(w0*2*t)','t',0,T/2);
for n=1:10;
a(1,n)=2*A/T*integrate('(cos(w0*t)+cos(w0*2*t))*cos(n*w0*t)','t',0,T/2);
b(1,n)=2*A/T*integrate('(cos(w0*t)+cos(w0*2*t))*sin(n*w0*t)','t',0,T/2);
end

## //Displaying fourier coefficients

disp(T,'fundamental period T= ',A,'Assumption: Amplitude A= ');
disp('Tignometric fourier series co-efficients:');
disp(a0,'a0= ');disp(a,'an= ');disp(b,'bn= ');

t=0:0.01*T:T/2;
x=[A*(cos(w0*t)+cos(w0*2*t)) zeros(1,50)];
t=0:0.01*T:T;
subplot(311);plot(t,x);
title('x(t)');xlabel('time t');
subplot(312);plot2d3(a);
title('Coefficients an');xlabel('n');

subplot(313);plot2d3(b);
title('Coefficients bn');xlabel('n');

## // Participant - C A Patil, Shweta Jain

//Plotting Continuous Time Fourier Transform (Spectrum of x(n))of
//Continuous Time Signal xa = cos(2*%pi*50*t)+cos(2*%pi*100*t)
clear;
clc;
close;
// Analog Signal
//A =1;

//Amplitude

Dt = 0.004;
t = -2:Dt:2;
xa = cos(2*%pi*50*t)+cos(2*%pi*100*t);
//
// Continuous-time Fourier Transform
Wmax = 2*%pi*100;

## //Analog Frequency = 100 Hz

K = 4;
k = 0:(K/500):K;
W = k*Wmax/K;
Xa = xa * exp(-sqrt(-1)*t'*W) * Dt;
Xa = real(Xa);
W = [-mtlb_fliplr(W), W(2:501)]; // Omega from -Wmax to Wmax
Xa = [mtlb_fliplr(Xa), Xa(2:501)];
subplot(2,1,1);
a =gca();

a.x_location = "origin";
a.y_location = "origin";
plot(t,xa);
xlabel('t in msec.');
ylabel('xa(t)')
title('Analog Signal')
subplot(2,1,2);
a =gca();
a.x_location = "origin";
a.y_location = "origin";
plot(W/(2*%pi),Xa);
xlabel('Frequency in Hz');
ylabel('Xa(jW)*1000')
title('Spectrum of x(n)')

## II. Best assignments

1. Vaishali Holkar
2. Vipul goswami
Assignment Question
CODE:
clear;
clc ;
close ;
t=0:0.01:0.2;
x1=cos(2*%pi*50*t)+cos(2*%pi*100*t) ;
subplot(1,2,1);
plot(t,x1);
xlabel('t');
ylabel('x(t)');
title('CONTINUOUS TIME PLOT');
n=0:0.2:2;

x2=cos(2*%pi*50*n)+cos(2*%pi*100*n);
subplot(1,2,2);
plot2d3(n,x2);
xlabel('n');
ylabel('x(n)');
title('DISCRETE TIME PLOT');
//Plotting spectrum of x(t)

N=8;n=0:N-1;
f1=50;f2=100;
x=cos(2*%pi*f1*n)+cos(2*%pi*f2*n);
L1=8;
for k=0:L1-1
P1(k+1)=1/N*abs(x*(cos(%pi*n*k/L1)-%i*sin(%pi*n*k/L1))')^2
end
L2=16;
for k=0:L2-1
P2(k+1)=1/N*abs(x*(cos(%pi*n*k/L2)-%i*sin(%pi*n*k/L2))')^2;
end
L3=32;
for k=0:L3-1
P3(k+1)=1/N*abs(x*(cos(%pi*n*k/L3)-%i*sin(%pi*n*k/L3))')^2;
end
subplot(311);
plot2d3(0:L1-1,P1);title('L=8');
subplot(312);
plot2d3(0:L2-1,P2);title('L=16');
subplot(313);
plot2d3(0:L3-1,P3);title('L=32');
//Plotting Continuous Time Fourier Transform (Spectrum of x(n))of
//Continuous Time Signal xa = cos(2*%pi*50*t)+cos(2*%pi*100*t)
clear;
clc;
close;
// Analog Signal
//A =1; //Amplitude
Dt = 0.004;
t = -2:Dt:2;
xa = cos(2*%pi*50*t)+cos(2*%pi*100*t);
//
// Continuous-time Fourier Transform
Wmax = 2*%pi*100;
//Analog Frequency = 100 Hz
K = 4;
k = 0:(K/500):K;

W = k*Wmax/K;
Xa = xa * exp(-sqrt(-1)*t'*W) * Dt;
Xa = real(Xa);
W = [-mtlb_fliplr(W), W(2:501)]; // Omega from -Wmax to Wmax
Xa = [mtlb_fliplr(Xa), Xa(2:501)];
subplot(2,1,1);
a =gca();
a.x_location = "origin";
a.y_location = "origin";
plot(t,xa);
xlabel('t in msec.');
ylabel('xa(t)')
title('Analog Signal')
subplot(2,1,2);
a =gca();
a.x_location = "origin";
a.y_location = "origin";
plot(W/(2*%pi),Xa);
xlabel('Frequency in Hz');
ylabel('Xa(jW)*1000')
title('Spectrum of x(n)')
X(t) and X(n)

Spectrum of X(t)

## III. Best assignment

SCILAB ASSIGNMENT
ASSIGNMENT-1
//Example 1.1
//we wish to sample the signalx(t)=cos(2*3.14*50*t)+cos(2*3.14*100*t)using
sampling freqvency of 250 hz, obtain the sample over the interval 0 to 0.2 sec, write
the appropriate scilab program and plot.
//1. X(t)

v/s

//PLOT: 1. X(t)

t
V/S

t=0:0.004:.0.2;
x=cos(2*%pi*50*t)+cos(2*%pi*100*t);
plot(t,x)

## // 2. plot: x(n) v/s n

clear;
clc ;
close ;
t=0:0.02:2;
x1=cos(2*3.14*50*t)+cos(2*3.14*100*t);
subplot(1,2,1);
plot(t,x1);
xlabel('t');
ylabel('x(t)');
title('CONTINUOUS TIME PLOT');
n=0:0.004:.2;
x2=cos(2*%pi*50*n*.004)+cos(2*%pi*100*n*.004);
subplot(1,2,2);
plot2d3(n,x2);
xlabel('n');
ylabel('x(n)');
title('DISCRETE TIME PLOT');

PLOT:

//3. PLOT:
t=0:0.004:.0.2;
x=cos(2*%pi*50*t)+cos(2*%pi*100*t);
plot(t,x)

// plot 4. Spectrum of the sampled version for each of the sampling freqvency over
the fre. Range fs to +fs.

//Graphical//
//Example 4.2.7 Sampling a Nonbandlimited Signal
//Plotting Continuous Time Fourier Transform of
//Continuous Time Signal x(t)= exp(-A*abs(t))
clear;
clc;
close;
// Analog Signal
Dt = 0.004;
t = -2:Dt:2;
xa = cos(2*%pi*50*t)+cos(2*%pi*100*t);
//
// Continuous-time Fourier Transform
Wmax = 2*%pi*100;

## //Analog Frequency = 100Hz

K = 4;
k = 0:(K/500):K;
W = k*Wmax/K;
Xa = xa * exp(-sqrt(-1)*t'*W) * Dt;
Xa = real(Xa);

## W = [-mtlb_fliplr(W), W(2:501)]; // Omega from -Wmax to Wmax

Xa = [mtlb_fliplr(Xa), Xa(2:501)];
subplot(2,1,1);
a =gca();
a.x_location = "origin";
a.y_location = "origin";
plot(t,xa);
xlabel('t in msec.');
ylabel('xa(t)')
title('Analog Signal')
subplot(2,1,2);
a =gca();
a.x_location = "origin";
a.y_location = "origin";
plot(W/(2*%pi),Xa);
xlabel('Frequency in Hz');
ylabel('Xa(jW)*1000')
title('Continuous-time Fourier Transform')