Skip to content

Commit 485a422

Browse files
authored
Add files via upload
1 parent b940b71 commit 485a422

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2807
-0
lines changed

Assignment/High_Pass_Filter.slx

20.2 KB
Binary file not shown.

Assignment/Low_Pass_Filter.slx

19 KB
Binary file not shown.

Assignment/Q1.m

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
%************ASSIGNMENT******************
2+
% Problem 1
3+
%Create a 10x10 random matrix with the command A=rand(10). Now do the following operations.
4+
% a) Multiply all elements by 100 and then round off all elements of the matrix to integers with the command A=fix(A).
5+
% b) Replace all elements of A<10 with Zeros.
6+
% c) Replace all elements of A>90 with infinity (inf).
7+
% d) Extract all 30 <= aij <= 50 in a vector b, that is find all elements between 30 and 50 and put them in a vector b.
8+
%
9+
A=rand(10);
10+
%%
11+
%(a)
12+
A=A*100;
13+
A=fix(A);
14+
%%
15+
%(b)
16+
A(A<10)=0;
17+
%%
18+
%(c)
19+
A(A>90)=inf;
20+
%%
21+
%(d)
22+
b=A(A>=30 & A<=50)
23+
24+

Assignment/Q2.m

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
% ****************ASSIGNMENT****************
2+
% 2. Find out the values of current il. 12 13 for the following given ckt using the
3+
% MATLAB R1=5 ohm, R2=100 ohm, R3=200 ohm,R4=150 ohm,R=250 ohm; V1= 5V and V2= 10V.
4+
% [V]= [R][I]
5+
% [i]= inv([R])[V]
6+
% -V1= (R1+R4)I1 + (-R4)I2 + (0)I3
7+
% 0= (-R4)I1 + (R2+R4+R5)I2 + (-R5)I3
8+
% -V2= (0)I1 + (-R5)I2 + (R3+R5)I3
9+
R1=5;
10+
R2=100;
11+
R3=200;
12+
R4=150;
13+
R5=250;
14+
V1=5;
15+
V2=10;
16+
V=[-V1;0;-V2];
17+
R=[R1+R4 -R4 0;
18+
-R4 R2+R4+R5 -R5;
19+
0 -R5 R3+R5];
20+
I=inv(R)*V;
21+
I

Assignment/Q3.m

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
% *********ASSIGNMENT*********************
2+
% 3. Write a program which does the following operation on given signal:
3+
% a) Addition, Multiplication and Convolution of two signal
4+
% b) Folding, Shifting and Scaling operation on a given signal
5+
%%
6+
%Let two DIGITAL signals are X, Y
7+
N=0:9;
8+
X=N;
9+
H=fliplr(N);%H=9:-1:0
10+
subplot(421); stem(N,X,'r'); title('Signals X');
11+
subplot(422); stem(N,H,'g'); title('Signals Y');
12+
%%
13+
%(a)Addition, Multiplication and Convolution
14+
Added=X+H;
15+
Product=X.*H;
16+
Convolution=conv(X,H);
17+
subplot(423); stem(N,Added,'b'); title('Added signals');
18+
subplot(424); stem(N,Product,'m'); title('Product signals');
19+
subplot(425); stem(-9:9,Convolution,'r'); title('Convolution signals');
20+
%stem(0:19,Convolution)
21+
%%
22+
%(b) Folding, Shifting and Scaling operation on a given signal
23+
%Folding using inbuilt function
24+
Folded1=fliplr(X);
25+
%Using for loop
26+
Folded2=[];
27+
for ij=length(X):-1:1
28+
Folded2=[Folded2 X(ij)];
29+
end
30+
subplot(426); stem(0:9,Folded2,'r'); title('Folded signals');
31+
%Shifing by 3 in right(Delay)
32+
N2=N+3;
33+
Shfited1(N2)=X;
34+
subplot(427); stem(0:11,Shfited1,'r'); title('Shifted signals');
35+
%Scaling by factor c=2
36+
Scaled=X(1:2:9);
37+
subplot(428); stem(0:4,Scaled,'r'); title('Scaled signals');

Assignment/Q4.m

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
%%
2+
% Q4. Program to draw fourier transform of trinangular function.
3+
T=4; %a= -2 to b= +2
4+
V0=5; %V=+-(10) Asussumed
5+
w= 2*pi/T;
6+
%%
7+
%Function declareation
8+
fun1= @(t)( (-4*V0/T).*(t + T/2) );
9+
fun2= @(t)( (4*V0/T).*t );
10+
fun3= @(t)( (-4*V0/T).*(t - T/2) );
11+
func= @(t)( fun1(t)+fun2(t)+fun3(t) );
12+
%%
13+
%a0, an & bn finding
14+
a10=@(n)(2/T)*integral( fun1, -T/2, -T/4 );
15+
a20=@(n)(2/T)*integral( fun2, -T/4, T/4 );
16+
a30=@(n)(2/T)*integral( fun3, T/4, T/2 );
17+
a0 =@(n)( a10(n)+a20(n)+a30(n) );
18+
19+
a1n=@(n)(2/T)*integral( @(t)fun1(t).*cos(n*w*t), -T/2, -T/4 );
20+
a2n=@(n)(2/T)*integral( @(t)fun2(t).*cos(n*w*t), -T/4, T/4 );
21+
a3n=@(n)(2/T)*integral( @(t)fun3(t).*cos(n*w*t), T/4, T/2 );
22+
an =@(n)( a10(n)+a20(n)+a30(n) );
23+
24+
b1n=@(n)(2/T)*integral( @(t)fun1(t).*sin(n*w*t), -T/2, -T/4 );
25+
b2n=@(n)(2/T)*integral( @(t)fun2(t).*sin(n*w*t), -T/4, T/4 );
26+
b3n=@(n)(2/T)*integral( @(t)fun3(t).*sin(n*w*t), T/4, T/2 );
27+
bn =@(n)( b1n(n)+b2n(n)+b3n(n) );
28+
%%
29+
t=-4:0.01:4;
30+
t1=-3:0.01:-1;
31+
t2=-1:0.01: 1;
32+
t3= 1:0.01: 3;
33+
%%
34+
for j=1:2:50
35+
36+
%hold on
37+
plot(t1,fun1(t1),'k')
38+
plot(t2,fun2(t2),'k')
39+
plot(t3,fun3(t3),'k')
40+
41+
FS=0;
42+
for k=1:j
43+
FS=FS + an(k).*cos(k*w*t)+bn(k).*sin(k*w*t);
44+
end
45+
FS=FS+a0(0);
46+
plot(t,t==0,'g',t==0,t,'g', t1,fun1(t1),'b', t2,fun2(t2),'b', t3, fun3(t3),'b',t,FS,'r' )
47+
pause(1)
48+
end

Assignment/Q5.m

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
%%
2+
%Amplitude modulation
3+
4+
Ac=2; fc=300;
5+
%mu=input('Enter Value of mu: ');
6+
%Am= mu*Ac;
7+
fm=25;
8+
9+
mt= @(t)sin(2*pi*fm*t);
10+
ct= @(t)sin(2*pi*fc*t);
11+
yt= @(t,mu)Ac*(1 + mu*mt(t)).*ct(t);
12+
13+
t=0:0.0001:0.1;
14+
subplot(5,1,1)
15+
plot( t,mt(t),'g' );
16+
title('Message Signal: m(t)');
17+
xlabel('time'); ylabel('Amplitude');
18+
19+
subplot(5,1,2)
20+
plot( t,2*ct(t),'b' );
21+
title('Career Signal: c(t)');
22+
xlabel('time'); ylabel('Amplitude');
23+
24+
subplot(5,1,3)
25+
plot( t,yt(t,0.5),'r' );
26+
title('Amplitude Modulated Signal: y(t): mu=0.5');
27+
xlabel('time'); ylabel('Amplitude');
28+
29+
subplot(5,1,4)
30+
plot( t,yt(t,1),'r' );
31+
title('Amplitude Modulated Signal: y(t): mu=1');
32+
xlabel('time'); ylabel('Amplitude');
33+
34+
subplot(5,1,5)
35+
plot( t,yt(t,1.5),'r' );
36+
title('Amplitude Modulated Signal: y(t): mu=1.5');
37+
xlabel('time'); ylabel('Amplitude');

Assignment/Q6.m

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
%%
2+
% Q6. Program to implement ASK, PSK And QAM
3+
b=randi(0:1,1,10);
4+
subplot(3,2,1);
5+
n=length(b);
6+
t=0:0.01:n;
7+
x=1:(n+1)*100;
8+
9+
for i=1:n
10+
for j=i:.1:i+1
11+
a(x(i*100:(i+1)*100))=b(i);
12+
end
13+
end
14+
a=a(100:end);
15+
plot(t,a,'r')
16+
title("Random Generated Bit Pattern"); xlabel("n");ylabel("Bit value");
17+
%%
18+
s=a.*sin(2*pi*5*t);
19+
subplot(3,2,2)
20+
plot(t,s,'g')
21+
title("ASK Plot"); xlabel("t");ylabel("Amplitude");
22+
%%
23+
%PSK
24+
for i=1:n
25+
if b(i)==0
26+
p(i)=-1;
27+
else
28+
p(i)=1;
29+
end
30+
for j=i:.1:i+1
31+
ps(x(i*100:(i+1)*100))=p(i);
32+
end
33+
end
34+
ps=ps(100:end);
35+
s=ps.*sin(2*pi*5*t);
36+
subplot(3,2,3)
37+
plot(t,s,'b')
38+
title("PSK Plot"); xlabel("t");ylabel("Amplitude");
39+
%%
40+
%FSK
41+
for i=1:n
42+
if b(i)==0
43+
p(i)=-1;
44+
else
45+
p(i)=1;
46+
end
47+
for j=i:.1:i+1
48+
f(x(i*100:(i+1)*100))=p(i);
49+
end
50+
end
51+
f=f(100:end);
52+
s=sin(2*pi*7.5*t+(2*pi*2.5*t).*f);
53+
subplot(3,2,4)
54+
plot(t,s,'m')
55+
title("FSK Plot"); xlabel("t");ylabel("Amplitude");
56+
%%
57+
M = 16;
58+
k = log2(M);
59+
n2 = 50000;
60+
nps = 1; % number per sample
61+
62+
rng default
63+
data = randi([0,1],n2,1);
64+
subplot(3,2,5);
65+
stem(data([1:40]));
66+
title('Random binary bits');
67+
xlabel('Bit index');
68+
ylabel('bits value');
69+
70+
four_bit_data = reshape(data , length(data)/k ,k); % creates 4 bit data for QAM
71+
datanew = bi2de(four_bit_data); % converts 4 bit binary data to decimal value
72+
73+
subplot(3,2,6);
74+
stem(datanew([1:40]));
75+
title('random value');
76+
xlabel('index value');
77+
ylabel('Integer value');
78+
79+
modulated_data = qammod(datanew , M ,'bin');
80+
Eb = 10;
81+
snr = Eb + 10*log10((k)/(nps));
82+
recieved_signal = awgn(modulated_data , snr , 'measured');
83+
84+
newplot = scatterplot(recieved_signal,1,0,'b.');
85+
hold on;
86+
scatterplot(modulated_data,1,0,'k+',newplot);
87+

Assignment/Q8.m

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
a = -100; b = 100;
2+
x=-100:100;
3+
mu = (a + b)/2;
4+
5+
6+
p1 = @(s)-0.5 * ((x - mu)/s) .^ 2;
7+
p2 = @(s)(s * sqrt(2*pi));
8+
f=@(s)exp(p1(s)) ./ p2(s);
9+
%%
10+
X = 100.*f(30); %sigma=30
11+
subplot(4,2,1)
12+
plot(x,X,'r')
13+
grid on
14+
title('X: Gauss Distribution:Bell Curve')
15+
xlabel('Randomly produced numbers')
16+
ylabel('Gauss Distribution')
17+
%%
18+
Y = 100.*f(10);
19+
subplot(4,2,2)
20+
plot(x,Y,'g')
21+
grid on
22+
title('Y: Gauss Distribution:Bell Curve')
23+
xlabel('Randomly Variables')
24+
ylabel('Gaussian Distribution')
25+
%%
26+
X2=X.^2;
27+
subplot(4,2,3)
28+
plot(x,X2,'b')
29+
grid on
30+
title('X^2, X: Gaussian')
31+
xlabel('Randomly Variables')
32+
ylabel('Gaussian Distribution')
33+
%%
34+
Y2=Y.^2;
35+
subplot(4,2,4)
36+
plot(x,Y2,'c')
37+
grid on
38+
title('Y^2, Y: Gaussian')
39+
xlabel('Randomly Variables')
40+
ylabel('Distribution')
41+
%%
42+
Z2=X2+Y2;
43+
subplot(4,2,5)
44+
plot(x,Z2,'m')
45+
grid on
46+
title('X^2+Y^2, X & Y: Gaussian')
47+
xlabel('Randomly Variables')
48+
ylabel('Distribution')
49+
%%
50+
Z=Z2.^0.5;
51+
subplot(4,2,6)
52+
plot(x,Z,'y')
53+
grid on
54+
title('Z=(X^2+Y^2)^0^.^5, X: Gaussian')
55+
xlabel('Randomly Variables')
56+
ylabel('Distribution')
57+
%%
58+
P=exp(X); %sigma=30
59+
subplot(4,2,7)
60+
plot(x,P,'k')
61+
grid on
62+
title('P= e^X, X: Gaussaian Distribution')
63+
xlabel('Randomly Variables')
64+
ylabel('Distribution')

Assignment/Q9.m

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
%%
2+
%Nakagami-m Distribution
3+
clc; clear all; close all;
4+
colors=['r','g','b'] ;
5+
m = 1;
6+
x = [0:0.05:3];
7+
subplot(411)
8+
for w = 1:3
9+
for ii = 1:length(x)
10+
y(ii)=((2*m^m)/(gamma(m)*w^m))*x(ii)^(2*m-1)*exp(-((m/w)*x(ii)^2));
11+
end
12+
plot(x,y,colors(w))
13+
hold on
14+
end
15+
xlabel('Support');
16+
ylabel('PDF');
17+
title('Nakagami-m Distribution:Probability Density Function')
18+
hleg1 = legend('w=1','w=2','w=3');
19+
set(hleg1,'Location','NorthEast')
20+
axis([0 3 0 2]);
21+
grid on
22+
%%
23+
x = (10:1000:125010)';
24+
y = lognpdf(x,log(20000),1.0);
25+
26+
subplot(412)
27+
plot(x,y)
28+
title('Log Normal Distribution')
29+
h = gca;
30+
h.XTick = [0 30000 60000 90000 120000];
31+
h.XTickLabel = {'0','$30,000','$60,000','$90,000','$120,000'};
32+
% Compute the Lognormal Distribution pdf
33+
% Suppose the income of a family of four in the United States follows
34+
% a lognormal distribution with mu = log(20,000) and sigma = 1.
35+
% Compute and plot the income density
36+
37+
%%
38+
mu = 1:5;
39+
40+
y = gampdf(1,1,mu);
41+
%y = [0.3679 0.3033 0.2388 0.1947 0.1637]
42+
y1 = exppdf(1,mu);
43+
subplot(413)
44+
plot(mu,y,mu,y1)
45+
title("Gamma Distribution Function")
46+
%%
47+
%Rician
48+
x = linspace(0, 8, 100);
49+
50+
subplot(4, 1, 4)
51+
plot(x, ricepdf(x, 0, 1), x, ricepdf(x, 1, 0.50), x, ricepdf(x, 1, 1.00))
52+
title('Rice PDF with s = 1')
53+
function y = ricepdf(x, v, s)
54+
s2 = s.^2; % (neater below)
55+
try
56+
y = (x ./ s2) .*...
57+
exp(-0.5 * (x.^2 + v.^2) ./ s2) .*...
58+
besseli(0, x .* v ./ s2);
59+
% besseli(0, ...) is the zeroth order modified Bessel function of
60+
% the first kind. (see help bessel)
61+
y(x <= 0) = 0;
62+
catch
63+
error('ricepdf:InputSizeMismatch','Non-scalar arguments must match in size.');
64+
end
65+
end
66+
%%

Calculator.fig

12 KB
Binary file not shown.

0 commit comments

Comments
 (0)