
































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Matlab code for: To generate a sine and cosine wave, verification of sampling theorem, verification of circular convolution, convolution of two input seque nces, transmitter and receiver for BPSK, design FIR digital High pass filter, To design FIR digital Low pass filter, To design IIR digital High pass filter, To design IIR digital low pass filter
Typology: Lab Reports
1 / 40
This page cannot be seen from the preview
Don't miss anything!

































MATLAB developed by The MathWorks Inc. stands for Matrix Laboratory.It is a software package used to perform scientific computations and visualization.Its compatibility for analysis of various scientific problems ,flexibility and powerful graphics make it a very useful software package.
Command Window display, giving you a "clean screen." After using clc, you cannot use the scroll bar to see the history of functions, but you still can use the up arrow to recall statements from the command history. Syntax: clc
code file or MEX-file function or variable name from your base workspace. If called from a function, clear name removes name from both the function workspace and in your base workspace. Syntax: clear name or clear name1 name2 name3 ... or clear keyword
alternative to the exist function, use the Workspace Browser or the Current Folder browser. Syntax: exist name or exist name kind
function has its own local variables, which are separate from those of other functions, and from those of the base workspace. global X Y Z defines X, Y, and Z as global in scope. Syntax: global X Y Z
description and the syntax for function_name in the Command Window.
The information is known as the help comments because it comes from the comments at the top of the MATLAB function file. Syntax: help or help function_name or help modelname.mdl
for the string topic in the first comment line (the H1 line) of the help text in all MATLAB program files found on the search path. lookfor topic -all searches the entire first comment block of a MATLAB program file looking for topic. Syntax: lookfor topic For example: lookfor inverse
confirm upon quitting preference is selected, and if confirmed or if the confirmation preference is not selected, terminates MATLAB after running finish.m, if finish.m exists. The workspace is not automatically saved by quit. To save the workspace or perform other actions when quitting, create a finish.m file to perform those actions. Syntax: quit or quit cancel
the top-level signal logging objects contained by log, where log is the handle of a Simulink.ModelDataLogs object name. Syntax: log.who or log.who('all')
top-level data logging objects in Simulink data log. Syntax: log.whos
existing current folder as a string to oldFolder, and then changes the
axis manipulates commonly used axes properties. axis([xmin xmax ymin ymax]) sets the limits for the x- and y-axis of the current axes. Syntax: axis([xmin xmax ymin ymax]) or axis auto or axis manual
specified limits. The function must be of the form y = f(x), where x is a vector whose range specifies the limits, and y is a vector the same size as x and contains the function's value at the points in x (see the first example). Syntax: fplot(fun,limits)
The grid function turns the current axes' grid lines on and off. grid on adds major grid lines to the current axes. grid off removes major and minor grid lines from the current axes.
of each value when Y is a real number. For complex Y, plot(Y) is equivalent to plot(real(Y),imag(Y)). plot(X1,Y1,...,Xn,Yn) plots each vector Yn versus vector Xn on the same axes. If one of Yn or Xn is a matrix and the other is a vector, plots the vector versus the matrix row or column with a matching dimension to the vector. If Xn is a scalar and Yn is a vector, plots discrete Yn points vertically at Xn.
copy output. All arguments to the print command are optional. You can use them in any combination or order.
graph.
Syntax: title(‘name of title’)
syntax : xlabel(‘label name’)
syntax : ylabel(‘label name’)
current figure using default property values. axes is the low-level function for creating axes graphics objects. MATLAB automatically creates an axes, if one does not already exist, when you issue a command that creates a graph.
specified figure(s). It optionally returns the status of the close operation.
objects. Figure objects are the individual windows on the screen in which the MATLAB software displays graphical output.
in the current figure window after you select a location with the mouse.
new graphics objects are added to the graph or replace objects in the graph. hold toggles the NextPlot property between the add and replace states.
various types of graphs (line plots, bar graphs, pie charts, etc.). For each line plotted, the legend shows a sample of the line type, marker symbol, and color beside the text label you specify. When plotting filled areas (patch or surface objects), the legend contains a sample of the face color next to the text label.
the current figure.
figure into rectangular panes that are numbered rowwise. Each pane
Matlab Function:- abs(x)=computes the absolute value o the elements o x, when x is complex , abs(x) is the complex magnitude of the elements of x. angle(x)=computes the phase angle of each component of the vector x. rem(n,N)=determines the reminder after dividing n and N. log 10(x)=compute the logarithm to the base 10 of the elements of x. mod(n,N)=compute n mod N. conv(x,h)=compute convolution of two sequences x and h. filter(b,a,x)=solves the difference equation given the input sequence x and difference equation coefficients b=[b1,b2,b3,.......bM] a=[a1,a2,a3,........aN] H=freqz(b,a,x) returns the frequency response at frequencies designated in vector w, in radians. [H,w]=freqz(b,a,N) returns an N-point frequency response vector and N-point frequency vector w in radians, where N is an integer and b,a are numerator and denominator coefficient vector. [R,p,k]=residuez(b,a) compute the residues ,poles in direct froms of the partical-fraction expansion of B(z)/A(z). fft(x,N) compute DFT of the sequence x using radix-2,N point FFT algorithem. ifft(X,N) compute IDFT of the sequence X using radix-2,N point FFT algorithem. w=boxcar(N0 returns the N-point rectangular window in array w.
w=bartlett(N) return the N-point triangular window. w=hamming(N) ) return the N-point Hamming window. w=hanning(N) return the N-point Hanning window. w=blackman(N) return the N-point Blackman window. w=kaiser(N,beeta) return the N-point Kaiser window function for the beeta value. [b,a]=butter [N,un] designs an Nth order lowpass digital Butterworth filter and returns the filter coefficients in length N+1 vectors b and a. wn is units of ∏. If wn=[w1,w2], this function returns an order 2N bandpass filter with 3dB passband w1<w<w2 in unit of ∏. [b,a]=butter [N,wn,’hight’] designs a hightpass digital Butterworth filter of order N and 3dB cutoff frequency wn in unit of ∏. [b,a]=butter[N1,wn’stop’] designs a band/digital Butterworth filter of order 2N with 3dB stopband w1<w<w2 in unit of ∏. [b,a]=cheby 1(N,Rp,wn) designs an Nth order lowpass digital Chebyshev 1 filter with Rp decibles of ripple in the passband. Wn is in units of ∏. b and a are filter co-efficients in length N+1.If wn =[w1,w2], this function returns an order 2N bandpass w1<w<w2. [b,a]=cheby(N,Rp,wn,’high’) designs a highpass digital Butterwoth filter of order N and 3dB cuttoff frequency wn in unit of ∏. [b,a]=cheby 1(N,Rp,wn,’stop’) designs an order 2N digital bandstop filter wn=[w1,w2] with 3dB stopband w1<w<w2 in unit of ∏. [b,a]=cheby 2(N,Rs,wn) designs an Nth order lowpass digital chebyshev 2filter with stopband attenuation Rs decibles.It returns the filter coefficients in length N+1 vectors b and a.If wn=[w1,w2],this
response (or the filter coefficients) are returned in array h of length N.The weighting function used in each band is equal to unity. [h]=remez(N,f,m,weigths) is similar to above function except weights specifies weighting function in each band. [h]=remez(N,f,m,ftype) is similar to first case except f type is the string ‘differentiator’ or ‘Hilbert’. [h]=remez(N,f,m,weights,ftype) is similar to the above case except that the array weight specifies the weighting function in each band. FilterSyntax: y = filter(b,a,X) Description: y = filter(b,a,X) filters the data in vector X with the filter described bynumerator coefficient vector b and denominator coefficient vector a.If a(1) is not equal to1, filter normalizes the filter coefficients by a(1). If a(1) equals 0, filter returns an error. ImpzSyntax: [h,t] = impz(b,a,n) Description: [h ,t ] = impz(b,a,n) computes the impulse response of the filter withn umerator coefficients b and denominator coefficients a and computes n samples of theimpulse response when n is an integer (t = [0:n-1]'). If n is a vector of integers,impzcomputes the impulse response at those integer locations , starting the responsecomputation from 0 (and t = n or t = [0 n]).If, instead of n, you include the empty vector [] for the second argument, the number of samples is computed automatically by default.
FliplrSyntax: B =fliplr(A) Description: B = fliplr(A) returns A with columns flipped in the left-right direction, thatis, about a vertical axis.If A is a row vector, then fliplr(A) returns a vector of the samelength with the order of its elements reversed. If A is a column vector, then fliplr(A)simply returns A.
Figure :-Response after adder block Figure:-Response after multiplier block
Figure:-Response after discrete system block(Discrete filter) At Display output was Amplitude of sine wave =0. Amplitude of constant signal = 1 Amplitude of step signal = Slope of ramp signal = 0.
Figure:-Response after subtractor block Figure :Response after multiplier block
Figure :-Response after continuous system block(Derivative) At Display output was Amplitude of sine wave =0. Amplitude of step signal = 1 Amplitude of pulse generator = Slope of ramp signal = 0.
T=0.04; %Time period of 50 Hz signal t=0:0.0005:0.02; f=1/T; xa_t=sin(2pi2t/T); subplot(2,2,1); plot(200t,xa_t); title ('continuous signal'); xlabel('t'); ylabel('x(t)'); ts1=0.002;%>niq rate ts2=0.01;%=niq rate ts3=0.1;%<niq rate n=0:20; x_ts1=sin(2pints1/T); subplot(2,2,2); stem(n,x_ts1); title('greater than Nq'); xlabel('n'); ylabel('x(n)'); n=0:4; x_ts2=sin(2pints2/T); subplot(2,2,3); stem(n,x_ts2); title('equal to Nq'); xlabel('n'); ylabel('x(n)'); n=0:4; x_ts3=sin(2pin*ts3/T); subplot(2,2,4); stem(n,x_ts3);
title('less than Nq'); xlabel('n'); ylabel('x(n)');