Skip to main content

Posts

Showing posts with the label MATLAB programs
Mat lab program to plot the ask modulated wave for a given binary sequence  %program to plot ask modulated wave clc; clear all; close all; f=2; t=0:(2*pi)/99:2*pi; g=input('Enter the binary sequence to be modulated '); bit=[];mod=[];c=[];cp=[]; for i=1:length(g)     if g(i)==0         die=zeros(1,100);         sp=zeros(1,100);     else g(i)==1         die=ones(1,100);         sp=ones(1,100);     end     c=sin(f*t);     bit=[bit die];     mod=[mod c];     cp=[cp sp]; end ask=cp.*mod; subplot(2,1,1) plot(bit); title('Binary bit pattern'); axis([0 100*length(g) -2.5 2.5]) grid on; subplot(2,1,2) plot(ask); axis([0 100*length(g) -2.5 2.5]) title('ASK modulated signal'); grid on;
Mat lab program to plot the frequency response of high pass filter  clc; clear all; close all; rp=1; rs=40; w1=800; w2=1200; ws=3600; aw1=2*pi*w1/ws; aw2=2*pi*w2/ws; pw1=2*tan(aw1/2); pw2=2*tan(aw2/2); [n,wc]=buttord(pw1,pw2,rp,rs,'s'); [b,a]=butter(n,wc,'high','s'); [num,den]=bilinear(b,a,1); [mag,freq]=freqz(num,den,128); freq1=freq*ws/(2*pi); m=20*log10(abs(mag)); plot(freq1,m); title('Respose of high pass filter'); grid on;
Mat lab program to plot the frequency response of low pass filter  clc; clear all; close all; rp=1; rs=40; w1=800; w2=1200; ws=3600; aw1=2*pi*w1/ws; aw2=2*pi*w2/ws; pw1=2*tan(aw1/2); pw2=2*tan(aw2/2); [n,wc]=buttord(pw1,pw2,rp,rs,'s'); [b,a]=butter(n,wc,'s'); [num,den]=bilinear(b,a,1); [mag,freq]=freqz(num,den,128); freq1=freq*ws/(2*pi); m=20*log10(abs(mag)); plot(freq1,m); title('Respose of low pass filter'); grid on;
Mat lab program to illustrate the impulse response of a LTI(linear time in-variant) system %program illustriating sampling theorem clc; clear all; close all; t=0:0.000005:0.5; f=16; t2=0:1/(1.3*f):0.5; s=cos(2*pi*f*t); sp=cos(2*pi*f*t2); subplot(3,1,1) plot(t,s,'b',t2,sp,'r*-'); hold on; stem(t2,sp,'g'); title('under sampling plot') ns=0:1/(2*f):0.5; ni=cos(2*pi*f*ns); subplot(3,1,2) plot(t,s,'b',ns,ni,'r*-') hold on; stem(ns,ni,'g'); title('nyquist sampling plot') os=0:1/(6*f):0.5;; ow=cos(2*pi*f*os); subplot(3,1,3) plot(t,s,'b',os,ow,'r*-') hold on; stem(os,ow,'g'); title('Over sampled plot') legend('analog signal','reconstructed signal','sampled signal'); 
Mat lab program to illustrate sampling theorem %program illustriating sampling theorem clc; clear all; close all; t=0:0.000005:0.5; f=16; t2=0:1/(1.3*f):0.5; s=cos(2*pi*f*t); sp=cos(2*pi*f*t2); subplot(3,1,1) plot(t,s,'b',t2,sp,'r*-'); hold on; stem(t2,sp,'g'); title('under sampling plot') ns=0:1/(2*f):0.5; ni=cos(2*pi*f*ns); subplot(3,1,2) plot(t,s,'b',ns,ni,'r*-') hold on; stem(ns,ni,'g'); title('nyquist sampling plot') os=0:1/(6*f):0.5;; ow=cos(2*pi*f*os); subplot(3,1,3) plot(t,s,'b',os,ow,'r*-') hold on; stem(os,ow,'g'); title('Over sampled plot') legend('analog signal','reconstructed signal','sampled signal'); 
Matlab program to generate sine ramp and square and their spectrum  %program to generate sine square ramp and their spectra clc; close all; clear all; f=10; t=0:0.001:0.5; s=sin(2*pi*f*t); subplot(3,1,1) plot(t,s) title('sine wave'); q=square(2*pi*50*t); subplot(3,1,2) plot(t,q) axis([0 0.2 -1.2 1.2]) title('square wave') subplot(3,1,3) plot(t,t); title('ramp wave'); figure(2) subplot(3,1,1) plot(abs(fft(s))); title('sine wave spectrum') subplot(3,1,2) plot(abs(fft(q))); title('square wave spectrum') subplot(3,1,3) plot(abs(fft(t))); title('ramp wave spectrum')
Matlab program for generating a truth table for logic equation and verify it %program to verify the logic equation clc; clear all; close all; a=[0 0 0 0 1 1 1 1]; b=[0 0 1 1 0 0 1 1]; c=[0 1 0 1 0 1 0 1]; f=(~a&~b&~c)|(~a&b&c)|(~a&~b&c)|(~a&b&c) 
Matlab program to plot VI characteristics of a diode  clc; close all; clear all; a=input('Enter the temperatre in degree centigrade '); b=input('Enter the reverse saturation current at room temperature '); q=1.6e-19; k=1.38e-23; t=a+273; v=-0.2:0.01:0.25; i=b*(exp(q*v/(k*t))-1); plot(v,i) xlabel('Voltage -->') ylabel('Current -->') grid on;