Program Name: Write A Matlab Program To Sample A Signal: Code
Program Name: Write A Matlab Program To Sample A Signal: Code
Code:
clc
clear all
t=5
f=100
y=0:(1/f):1;
x=sin(2*pi*t*y);
t1=0:(1/(2.5*f)):1;
x1=sin(2*pi*t*t1);
t2=0:(1/(0.5*f)):1;
x2=sin(2*pi*t*t2);
subplot(3,2,1);
plot(y,x);
title('message');
xlabel('t');
ylabel('x');
subplot(3,2,5);
plot(t1,x1);
title('message more than nyquest rate');
xlabel('t1');
ylabel('x1');
subplot(3,2,3);
plot(t2,x2);
title('message less than nyquest rate');
xlabel('t2');
ylabel('x2');
subplot(3,2,2);
stem(y,x);
title('sample of message');
xlabel('t');
ylabel('x');
subplot(3,2,6);
stem(t1,x1);
title('sample more than nyquest rate');
xlabel('x1');
ylabel('t1');
subplot(3,2,4);
stem(t2,x2);
title('sample less than nyquest rate');
xlabel('x2');
ylabel('t2');
Output:
Program Name: Write a Matlab program to quantize a signal.
Code:
clc
clear all
fm=0.0001;
t=0:.00001:20*fm;
x=sin(2000*pi*t);
partition = [-1:0.2:1];
codebook = [-1.2:0.2:1];
[index,quants] = quantiz(x,partition,codebook);
plot(t,x,t,quants);
Output: