clc;
close all;
clear all;
t = 0:.001:2*pi; % Times at which to sample the sine function
sig = sin(2*t); % Original signal, a sine wave
partition = [-1:2/15:1]; % Length 21, to represent 22 intervals
codebook = [0:1:16]; % Length 22, one entry for each interval
quants= quantiz(sig,partition,codebook); % Quantize.
figure(1)
plot(t,sig,t,quants),grid
legend('Original signal','Quantized signal');
figure(2)
r=de2bi(quants,'left-msb');
s=length(quants)
%rL=length(r)
res=reshape(r,1,4*length(r))% this is the binary data of the original sinwave.
stem(res)%to see the 0-1 data ploted
%rL=length(res)
%tr=[1:1:rL]/rL;
%y=sin(2*pi*50*tr);
%jj=res.*y;
%figure;
%plot(tr,jj),grid;
%axis([-.2 7 -2 2])
%clc;
%close all;
%clear all;
%t = 0:.001:2*pi; % Times at which to sample the sine function
%sig = sin(2*t); % Original signal, a sine wave
%partition = [-1:2/15:1]; % Length 21, to represent 22 intervals
%codebook = [0:1:16]; % Length 22, one entry for each interval
%quants= quantiz(sig,partition,codebook); % Quantize.
%figure(1)
%plot(t,sig,t,quants),grid
%legend('Original signal','Quantized signal');
%figure(2)
%r=de2bi(quants,'left-msb');
%s=length(quants)
%rL=length(r)
%res=reshape(r,1,4*length(r))% this is the binary data of the original sinwave.
%stem(res)%to see the 0-1 data ploted
%rL=length(res)
%tr=[1:1:rL]/rL;
%y=sin(2*pi*50*tr);
%jj=res.*y;
%figure;
%plot(tr,jj),grid;
%axis([-.2 7 -2 2])
%clc;
%close all;
%clear all;
%t = 0:.001:2*pi; % Times at which to sample the sine function
%sig = sin(2*t); % Original signal, a sine wave
%partition = [-1:2/15:1]; % Length 21, to represent 22 intervals
%codebook = [0:1:16]; % Length 22, one entry for each interval
%quants= quantiz(sig,partition,codebook); % Quantize.
%figure(1)
%plot(t,sig,t,quants),grid
%legend('Original signal','Quantized signal');
%figure(2)
%r=de2bi(quants,'left-msb');
%s=length(quants)
%rL=length(r)
%res=reshape(r,1,4*length(r))% this is the binary data of the original sinwave.
%stem(res)%to see the 0-1 data ploted
%rL=length(res)
%tr=[1:1:rL]/rL;
%y=sin(2*pi*50*tr);
%jj=res.*y;
%figure;
%plot(tr,jj),grid;
%axis([-.2 7 -2 2])
%clc;
%close all;
%clear all;
%t = 0:.001:2*pi; % Times at which to sample the sine function
%sig = sin(2*t); % Original signal, a sine wave
%partition = [-1:2/15:1]; % Length 21, to represent 22 intervals
%codebook = [0:1:16]; % Length 22, one entry for each interval
%quants= quantiz(sig,partition,codebook); % Quantize.
%figure(1)
%plot(t,sig,t,quants),grid
%legend('Original signal','Quantized signal');
%figure(2)
%r=de2bi(quants,'left-msb');
%s=length(quants)
%rL=length(r)
%res=reshape(r,1,4*length(r))% this is the binary data of the original sinwave.
%stem(res)%to see the 0-1 data ploted
%rL=length(res)
%tr=[1:1:rL]/rL;
%y=sin(2*pi*50*tr);
%jj=res.*y;
%figure;
%plot(tr,jj),grid;
%axis([-.2 7 -2 2])
%clc;
%close all;
%clear all;
%t = 0:.001:2*pi; % Times at which to sample the sine function
%sig = sin(2*t); % Original signal, a sine wave
%partition = [-1:2/15:1]; % Length 21, to represent 22 intervals
%codebook = [0:1:16]; % Length 22, one entry for each interval
%quants= quantiz(sig,partition,codebook); % Quantize.
%figure(1)
%plot(t,sig,t,quants),grid
%legend('Original signal','Quantized signal');
%figure(2)
%r=de2bi(quants,'left-msb');
%s=length(quants)
%rL=length(r)
%res=reshape(r,1,4*length(r))% this is the binary data of the original sinwave.
%stem(res)%to see the 0-1 data ploted
%rL=length(res)
%tr=[1:1:rL]/rL;
%y=sin(2*pi*50*tr);
%jj=res.*y;
%figure;
%plot(tr,jj),grid;
%axis([-.2 7 -2 2])
%clc;
%close all;
%clear all;
%t = 0:.001:2*pi; % Times at which to sample the sine function
%sig = sin(2*t); % Original signal, a sine wave
%partition = [-1:2/15:1]; % Length 21, to represent 22 intervals
%codebook = [0:1:16]; % Length 22, one entry for each interval
%quants= quantiz(sig,partition,codebook); % Quantize.
%figure(1)
%plot(t,sig,t,quants),grid
%legend('Original signal','Quantized signal');
%figure(2)
%r=de2bi(quants,'left-msb');
%s=length(quants)
%rL=length(r)
%res=reshape(r,1,4*length(r))% this is the binary data of the original sinwave.
%stem(res)%to see the 0-1 data ploted
%rL=length(res)
%tr=[1:1:rL]/rL;
%y=sin(2*pi*50*tr);
%jj=res.*y;
%figure;
%plot(tr,jj),grid;
%axis([-.2 7 -2 2])
%clc;
%close all;
%clear all;
%t = 0:.001:2*pi; % Times at which to sample the sine function
%sig = sin(2*t); % Original signal, a sine wave
%partition = [-1:2/15:1]; % Length 21, to represent 22 intervals
%codebook = [0:1:16]; % Length 22, one entry for each interval
%quants= quantiz(sig,partition,codebook); % Quantize.
%figure(1)
%plot(t,sig,t,quants),grid
%legend('Original signal','Quantized signal');
%figure(2)
%r=de2bi(quants,'left-msb');
%s=length(quants)
%rL=length(r)
%res=reshape(r,1,4*length(r))% this is the binary data of the original sinwave.
%stem(res)%to see the 0-1 data ploted
%rL=length(res)
%tr=[1:1:rL]/rL;
%y=sin(2*pi*50*tr);
%jj=res.*y;
%figure;
%plot(tr,jj),grid;
%axis([-.2 7 -2 2])
%clc;
%close all;
%clear all;
%t = 0:.001:2*pi; % Times at which to sample the sine function
%sig = sin(2*t); % Original signal, a sine wave
%partition = [-1:2/15:1]; % Length 21, to represent 22 intervals
%codebook = [0:1:16]; % Length 22, one entry for each interval
%quants= quantiz(sig,partition,codebook); % Quantize.
%figure(1)
%plot(t,sig,t,quants),grid
%legend('Original signal','Quantized signal');
%figure(2)
%r=de2bi(quants,'left-msb');
%s=length(quants)
%rL=length(r)
%res=reshape(r,1,4*length(r))% this is the binary data of the original sinwave.
%stem(res)%to see the 0-1 data ploted
%rL=length(res)
%tr=[1:1:rL]/rL;
%y=sin(2*pi*50*tr);
%jj=res.*y;
%figure;
%plot(tr,jj),grid;
%axis([-.2 7 -2 2])
%clc;
%close all;
%clear all;
%t = 0:.001:2*pi; % Times at which to sample the sine function
%sig = sin(2*t); % Original signal, a sine wave
%partition = [-1:2/15:1]; % Length 21, to represent 22 intervals
%codebook = [0:1:16]; % Length 22, one entry for each interval
%quants= quantiz(sig,partition,codebook); % Quantize.
%figure(1)
%plot(t,sig,t,quants),grid
%legend('Original signal','Quantized signal');
%figure(2)
%r=de2bi(quants,'left-msb');
%s=length(quants)
%rL=length(r)
%res=reshape(r,1,4*length(r))% this is the binary data of the original sinwave.
%stem(res)%to see the 0-1 data ploted
%rL=length(res)
%tr=[1:1:rL]/rL;
%y=sin(2*pi*50*tr);
%jj=res.*y;
%figure;
%plot(tr,jj),grid;
%axis([-.2 7 -2 2])
%clc;
%close all;
%clear all;
%t = 0:.001:2*pi; % Times at which to sample the sine function
%sig = sin(2*t); % Original signal, a sine wave
%partition = [-1:2/15:1]; % Length 21, to represent 22 intervals
%codebook = [0:1:16]; % Length 22, one entry for each interval
%quants= quantiz(sig,partition,codebook); % Quantize.
%figure(1)
%plot(t,sig,t,quants),grid
%legend('Original signal','Quantized signal');
%figure(2)
%r=de2bi(quants,'left-msb');
%s=length(quants)
%rL=length(r)
%res=reshape(r,1,4*length(r))% this is the binary data of the original sinwave.
%stem(res)%to see the 0-1 data ploted
%rL=length(res)
%tr=[1:1:rL]/rL;
%y=sin(2*pi*50*tr);
%jj=res.*y;
%figure;
%plot(tr,jj),grid;
%axis([-.2 7 -2 2])
%clc;
%close all;
%clear all;
%t = 0:.001:2*pi; % Times at which to sample the sine function
%sig = sin(2*t); % Original signal, a sine wave
%partition = [-1:2/15:1]; % Length 21, to represent 22 intervals
%codebook = [0:1:16]; % Length 22, one entry for each interval
%quants=