FUNDAMENTAL OF MAT LAB
A
Report
Submitted
in partial fulfillment
for the award of the Degree of
Master of Technology
in Department of Digital Communication Engineering
Submitted By:
Rakesh Kumar Bazad
ACKNOWLEDGEMENT
It is great opportunity to express my sincere thanks to all who have contributed to do this project through their support, encouragement and guidance
Rakesh Kumar Bazad
INDEX
1. INTRODUCTION
1.1 Introduction
1.2 Features of mat lab
2. MATHAMATIC FUNCTION
2.1 Elementary functions
2.2 Examples
3 MAT LAB FUCTIONS
3.1 MAT lab function
3.2 Create mat lab function
3.3 first line of mat lab function
3.4 Variables
3.5 Output Variable
3.6 Save a mat lab file
3.7 Run a mat lab file
4. Basic Plotting
4.1 Overview of plotting
4.2 Create a plot
5. OPERATIONS
5.1 Array
5.2 Long Array
6. APPLICATIONS
7. REFRENCE
1. INTRODUCTION
1.1 Introduction :
Matlab is basically a high level language which has many specialized toolboxes for making things easier for us
The name MATLAB stands for MATrix LABoratory. MATLAB was written originallyto provide easy access to matrix software developed by the LINPACK (linear system package)and EISPACK (Eigen system package) projects.
MATLAB is a high-performance language for technical computing. It integrates computation, visualization, and programming environment. Furthermore, MATLAB is a modern programming language environment: it has sophisticated data structures, contains built-in editing and debugging tools, and supports object-oriented programming. These factors make MATLAB an excellent tool for teaching and research.
MATLAB has many advantages compared to conventional computer languages (e.g., C, FORTRAN) for solving technical problems. MATLAB is an interactive system whose basic data element is an array that does not require dimensioning.
1.2 Features of mat lab :
1. Mat lab commands
2. Input output capability
3. Command line
4. Mat-files
5. Data storage
2. Mathematical functions
2.1 Elementary functions:
cos(x) Cosine abs(x) Absolute value
sin(x) Sine sign(x) Signum function
tan(x) Tangent max(x) Maximum value
acos(x) Arc cosine min(x) Minimum value
asin(x) Arc sine ceil(x) Round towards +1
atan(x) Arc tangent floor(x) Round towards ¡1
exp(x) Exponential round(x) Round to nearest integer
sqrt(x) Square root rem(x) Remainder after division
log(x) Natural logarithm angle(x) Phase angle
log10(x) Common logarithm conj(x) Complex conjugate
2.2 Examples of elementary functions:
1. The value of the expression y = e¡a sin(x) + 10
p
y, for a = 5, x = 2, and
y = 8 is computed by
>> a = 5; x = 2; y = 8;
>> y = exp(-a)*sin(x)+10*sqrt(y)
y =
28.2904
2. The subsequent examples are
>> log(142)
ans =
4.9558
>> log10(142)
ans =
2.1523
3. MATLAB Functions
3.1 MATLAB function:
A MATLAB “function” is a MATLAB program that performs a sequence of operations specified
in a text file (called an m-file because it must be saved with a file extension of *.m). A function
accepts one or more MATLAB variables as inputs, operates on them in some way, and then
returns one or more MATLAB variables as outputs and may also generate plots, etc.
3.2 Create a new MATLAB function :
Since an m-file is nothing more than a text file it can be created using any text editor – however,
MATLAB provides its own editor that provides some particular features that are useful when
writing/editing functions.
To open a new m-file: In the MATLAB command window, go to FILE on the toolbar, select
NEW, then select M-FILE. This opens the MATLAB editor/debugger and gives an empty file in
which you can create whatever m-file you want.
3.3 First Line of a MATLAB function :
The 1st line of a function must contain the “function definition,” which has a general structure like this
1: function [Out_1,Out_2,…,Out_N] = function_name(In_1,In_2,…,In_M)
where Out_1,Out_2,…,Out_N are the N output variables and In_1,In_2,…,In_M are the M input variables;
If there is only a single output variable use:
function Out_1 = function_name(In_1,In_2,…,In_M)
If there is no output variable use:
function function_name(In_1,In_2,…,In_M)
3.4 Variables :
All variables are created with double precision unless specified and they are matrices.
Example :
>>x=5;
>>y=2;
3.5 Output variable :
On any line in your function you can assign any result you compute to any one of the output variables specified.
Example:
Out=cos(y);
will compute the cosine of the values in the variable y and then assigns the result to the variable Out, which will then be output by the function.
3.6 Save a mat lab function :
Once you have finished writing your function you have to save it as an m-file before you can use it. This is done in the same way you save a file in any other application:
• go to FILE, and SAVE.
• type in the name that you want to use
o it is best to always use the “function name” as the “file name”
o you don’t need to explicitly specify the file type as *.m
• navigate to the folder where you want to save the function file
o see below for more details on “Where to Save an M-File?”
• click on SAVE
3.7 Run an M-File :
Once you have a function saved as an m-file with a name the same as the function name and in a folder that is either the PWD or is in MATLAB’s path, you can run it from the command line:
>> [Out_1,Out_2,…,Out_N] = function_name(In_1,In_2,…,In_M)
4. Basic plotting
4.1 overview of plotting :
MATLAB has an excellent set of graphic tools. Plotting a given data set or the results of computation is possible with very few commands. You are highly encouraged to plot mathematical functions and results of analysis as often as possible. Trying to understand mathematical equations with graphics is an enjoyable and very e±cient way of learning mathematics. Being able to plot mathematical functions and data freely is the most important step, and this section is written to assist you to do just that
4.2 Creating simple plots:
The basic MATLAB graphing procedure, for example in 2D, is to take a vector of x-coordinates, x = (x1; : : : ; xN), and a vector of y-coordinates, y = (y1; : : : ; yN), locate the points (xi; yi), with i = 1; 2; : : : ; n and then join them by straight lines. You need to prepare x and y in an identical array form; namely, x and y are both row arrays or column arrays of the same length.
The MATLAB command to plot a graph is plot(x,y). The vectors x = (1; 2; 3; 4; 5; 6) and y = (3;¡1; 2; 4; 5; 1)
>> x = [1 2 3 4 5 6];
>> y = [3 -1 2 4 5 1];
>> plot(x,y)
5.Operations
5.1 Array :
a vector x = [1 2 5 1]
x =
1 2 5 1
a matrix x = [1 2 3; 5 1 4; 3 2 -1]
x =
1 2 3
5 1 4
3 2 -1
A transpose y = x’ y =
1
2
5
1
5.2 Long Array :
t =1:10
t =
1 2 3 4 5 6 7 8 9 10
k =2:-0.5:-1
k =
2 1.5 1 0.5 0 -0.5 -1
B = [1:4; 5:8]
x =
1 2 3 4
5 6 7 8
6.Application of Mat lab
1. Mathematical Calculations
2. Data Analysis & Visualization
3. Software Development
4. Simulation
7.Refrence
1. www.google.co.in
2.www.yahoo.com


9:38 AM
jhon
Posted in:
0 comments:
Post a Comment