Matlab Introduction


Published on

A basic overview, application and usage of MATLAB for engineers. It covered very basics essential that will help one to get started with MATLAB programming easily.

Provided by IDEAS2IGNITE

Published in: Technology
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • This presentation demonstrates the new capabilities of PowerPoint and it is best viewed in Slide Show. These slides are designed to give you great ideas for the presentations you’ll create in PowerPoint 2010!For more sample templates, click the File tab, and then on the New tab, click Sample Templates.
  • Special meaning is sometimes attached to 1-by-1 matrices, which are scalars, and to matrices with only one row or column, which are vectors. MATLAB has other ways of storing both numeric and nonnumeric data, but in the beginning, it is usually best to think of everything as a matrix.Magic Squares are special matrix whose row, column and diagonal sum are all equal. Considered to be very auspecious.
  • Colon operator replaces the much used for loops for array referencing used in conventional programming language.
  • Matlab Introduction

    1. 1. A Training for Engineers<br />introducingMATLAB<br />
    2. 2. Making you a better Engineer<br />1<br />3<br />2<br />Basic MATLAB Programming<br />Advanced MATLAB<br />Engineering Applications<br />Redefine your engineering<br />
    3. 3. Basic MATLAB Programming<br />Design, organize, and collaborate<br />1<br />
    4. 4. Session 1<br />MATLAB Overview<br /><ul><li> What is MATLAB?
    5. 5. Various use cases of MATLAB
    6. 6. MATLAB environment
    7. 7. OCTAVE Introduction and installation
    8. 8. MATLAB Vs OCTAVE</li></li></ul><li>Session 1: What is MATLAB<br />A High level programming Language.<br />An interactive technical computing environment.<br />Algorithm Development<br />Data Analysis and visualization <br />Numerical Computation.<br />Faster than traditional computing Language like C, C++ and Fortran.<br />
    9. 9.
    10. 10. MATLAB - Application Domain<br />Numerical computation: linear algebra, statistics, Fourier analysis, filtering, optimization, and numerical integration<br />Signal and Image processing<br />Communication Systems<br />Control Design<br />Test and measurement.<br />Financial Modeling and Analysis<br />Computational Biology.<br />Virtually Any engineering domain. <br />
    11. 11. Developing Algorithm and Applications<br />MATLAB language supports vectors and matrix operations fundamental in engineering<br />No need for low level administrative tasks like variable declaration, specifying data types and allocating data types. <br />No need for compilation and linking (JIT).<br />Easy design of Graphical user interface (GUI).<br />Development Tools: MATLAB Editor, M-lint Code Checker, MATLAB profile, Directory Report.<br />
    12. 12. Analyzing and accessing data<br />MATLAB supports entire data analysis process - from acquiring data, to preprocessing, visualization, and numerical analysis, to quality output.<br />MATLAB product provides interactive tools and command-line functions for data analysis operations, including interpolation, decimation, correlation, Fourier analysis, statistics functions and matrix analysis. <br />MATLAB is an efficient platform for accessing data from files, other applications, databases, and external devices through serial ports and sound cards, popular file formats such as Microsoft Excel; ASCII text or binary files; image, sound, and video files; and scientific files, such as HDF and HDF5, web-pages and XML. <br />
    13. 13. Visualizing Data<br />All the graphics features that are required to visualize engineering and scientific data are available in MATLAB®. These include 2-D and 3-D plotting functions, 3-D volume visualization functions. <br />2-D Plotting: Line, area, bar, and pie chart, histogram, polygon and surface, scatter.<br />3-D Plotting: Surface, contour, mesh, image, iso-surface.<br />MATLAB lets you read and write common graphical and data file formats, such as GIF, JPEG, BMP, EPS, TIFF, PNG, HDF, AVI, and PCX.<br />
    14. 14. Publishing Results and Deploying Applications<br />Publishing Results: Using the MATLAB Editor, you can automatically publish your MATLAB code in HTML, Word, LaTEX, and other formats.<br />MATLAB provides functions for integrating C and C++ code, Fortran code, COM objects, and Java code with your applications. You can call DLLs, Java classes, and ActiveX controls.<br />Using the MATLAB engine library, you can also call MATLAB from C, C++, or Fortran code.<br />Deploying applications: Create your algorithm in MATLAB and distribute it to other MATLAB users directly as MATLAB code. <br />Using the MATLAB Compiler (available separately), you can deploy your algorithm, as a stand-alone application or as a software module that you include in your project, to users who do not have MATLAB. <br />
    15. 15. Getting Started to MATLAB<br />An introductory video taken from MATLAB Product Page.<br />Curtsey : MATLAB Inc<br />
    16. 16. MATLAB Environment<br />The MATLAB desktop environment consist of four main windows: <br />Command Window <br />Command History<br />Current Folder Window <br /> Workspace Browser<br />
    17. 17. Description<br />Command Window: A place where you type the command and instruction of MATLAB.<br />Command History records all the commands entered in the command window.<br />The Current folder is the directory where you can save your work. <br />Go to File->Set Path to set the list of folders to be included in the search path. <br />All the files and folders of the current folder are listed in the current folder browser. <br />Workspace Browser is a place where all variables in the MATLAB’s current session are stored and accessed.<br />
    18. 18. OCTAVE<br />GNU Octave is a high-level language, primarily intended for numerical computations. <br />It provides a convenient command line interface for solving linear and nonlinear problems numerically.<br />It is mostly compatible with MATLAB.<br />Interpreter provides convenient CLI. (using libreadline)<br />
    19. 19. Octave – Continued <br />GNU Octave is a freely redistributable software. <br />Octave and Octave-forge includes a large set of toolbox present in MATLAB. <br />Easily extendible in C++ using a well designed library.<br />Uses tried and tested FORTRUN routine in backend. <br />Community support on a very active mailing list. <br />Well supported on Linux and MacOS. <br />
    20. 20. Octave – The Down Side<br />Windows Platform support is not good (using cygwin)<br />Dependent on volunteers and the quality of their work. <br />IDE, profiler and GUI Lacking. <br />Plots using GNUPlot which poses some problems – improvement on the way. <br />Compiler (Just-in-time?)<br />Domain Specific packages not mature. <br />
    21. 21. Installation (OCTAVE/MATLAB)<br />
    22. 22. Too much information?<br />We will go slow and try to cover important aspects and use cases of MATLAB .<br />End of Session 1<br />?<br />Ask Questions for the sake of those sitting around you.<br />
    23. 23. Session 2<br />MATLAB Programming<br />Basic Data types<br />Matrix and Linear Algebra<br />Programming constructs and M-Files<br />Data Import and export`<br />Plots and Plotting tools<br />MATLAB Control flow <br />
    24. 24. MATLAB is MATrixLABoratory<br />In the MATLAB environment, a matrix is a rectangular array of numbers.<br />Entering Matrix into MATLAB<br />Explicit list of elements.<br />Load from external files.<br />Generate matrix using Built-in functions.<br />By default, MATLAB functions operate directly on matrix and no iteration logic need be implemented. <br />
    25. 25. Hands on Session: S2C1<br />% MATLAB Workshop For engineers<br />% Author: Mayank Kumar<br />% Company: IDEAS2IGNITE<br />% Date: 20/09/2010<br />%%Demonstrating MATRIX Manipulations<br />a=[8 1 6;3 5 7;4 9 2]<br />b=sum(a)<br />c=sum(a')'<br />d=sum(diag(a))<br />e=sum(diag(fliplr(a)))<br />MATLA has a preference of working with column of Matrix. <br />By default, ,MATLAB stores answer in ans variables. <br />Transpose of Matrix<br />Diagonal of Matrix<br />
    26. 26. Accessing MATrix Elements<br />The element in row i and column j of A is denoted by A(i,j).<br />It is also possible to refer to the elements of a matrix with a single subscript, A(k).<br />Matrix size is adaptive and increase with assignments outside the limits. <br />Referring to outside location leads to error. <br />
    27. 27. Colon Operator<br />Colon operator helps in generating Arithmetic Sequences which are used to refer to Matrix elements in bulk. <br />A:k:B => A sequence starting from A and ending on or before B with separation of K. <br />A:B => Default separation of 1.<br />: => Sequence range automatically guessed from matrix size. Read as ‘ALL’<br />
    28. 28. Hands on Session: S2C2<br />%% Understanding Colon Operators<br />A=rand(10,10);<br />B=A(:);<br />stem(B,'.')<br />mean(B)<br />figure<br />hist(B,10)<br />%% More use of Colon Operator<br />% Set all values greater than 0.8 to 0<br />B(B>0.8)=0;<br />figure<br />hist(B)<br />Smart use of colon operators to avoid for loops decrease program execution times. <br />Matrix reference can be done using logic matrix. <br />
    29. 29. Basic Programming components<br />Variables<br />Operators<br />MATLAB expression<br />Functions<br />MATrix<br />
    30. 30. Variables and Numbers<br />MATLAB does not require any type declarations or dimension statements.<br />MATLAB uses conventional decimal notation,<br />Scientific notation uses the letter e to specify a power-of-ten scale factor.<br />Imaginary numbers use either I or j as a suffix.<br />MATLAB stores all numbers internally using the long format specified by the IEEE® floating-point standard.<br />
    31. 31. MALAB Data Types<br />
    32. 32. Integers<br />
    33. 33. Floating Point Numbers <br />MATLAB construct double precision data type according to IEEE Standard 754. (64-bit)<br />MATLAB construct single precision data type according to IEEE Standard 754. (32-bit)<br />Precision consideration is very important when choosing the data-type for your computation. <br />If you are aiming for embedded applications, you might have to make your algorithm work in single precisions.<br />
    34. 34. Hands on Session: S2C3<br />
    35. 35. Complex Numbers<br />Complex numbers consist of two separate parts: a real part and an imaginary part. The basic imaginary unit is equal to the square root of -1.<br />This is represented in MATLAB by either of two letters: i or j.<br />Complex, real, imag, isreal<br />
    36. 36. Infinity and NaN<br />MATLAB uses the special values inf, -inf, and NaN to represent values that are positive and negative infinity, and not a number respectively.<br />MATLAB represents infinity by the special value inf. Infinity results from operations like division by zero and overflow, which lead to results too large to represent as conventional floating-point values. <br />Use the isinf function to verify that x is positive or negative infinity.<br />
    37. 37. Operators<br />
    38. 38. MATLAB Functions <br />MATLAB provides a large number of standard elementary mathematical functions and other application domain functions.<br />These functions treat scalar and vectors in similar way.<br />They work both for real and complex data making complex computation very easy. <br />Some of the functions are built in. Built-in functions are part of the MATLAB core so they are very efficient, but the computational details are not readily accessible. Other functions are implemented in the MATLAB programing language, so their computational details are accessible.<br />help elfun<br />help specfun<br />help elmat<br />
    39. 39. Hands on Session: S2C4<br />function [roots flag]=quadratic(a,b,c)<br />if nargin==1<br /> roots=[0 0];<br /> flag=1; %Equal roots<br />else<br /> if(a==0)<br />fprintf('a must not be equal to zero')<br /> roots=[NaNNaN];<br /> flag=NaN;<br /> else<br /> alpha=(-b+sqrt(b.^2-4*a.*c))./(2.*a);<br /> beta=(-b-sqrt(b.^2-4*a.*c))./(2.*a);<br /> roots=[alpha beta];<br /> if(b.^2-4*a.*c==0)<br /> flag=1; %equal oots<br /> else<br /> flag=0; %unequall roots<br /> end<br /> end<br /> end<br />How to make a custom MATLAB Functions<br />
    40. 40. Back to MATrixLABoratory<br />Standard Matrix Generation<br />Zeros, Ones, Eye, Rand, randn<br />Load function can be used to read binary files containing matrix from earlier session or text file containing data. <br />Concatenation Concatenation is the process of joining small matrices to make bigger ones. In fact, you made your first matrix by concatenating its individual elements. The pair of square brackets, [], is the concatenation operator.<br />Rows or column can be deleted using a pair of square brackets. <br />
    41. 41. Linear Algebra<br />Determinant: det(A)<br />reduced row echelon form: rref(A)<br />Matrix Inversion: inv(A)<br />Eigenvalues: eig(A)<br />Coefficient of Characteristic polynomial: poly(A)<br />Matrix Functions are column dominated. <br />
    42. 42. Application: Solving Linear Equations<br />One of the most important problems in technical computing is the solution of simultaneous linear equations. In matrix notation, this problem can be stated as follows.<br />X = AB: Denotes the solution to the matrix equation AX = B.<br />X = B/A: Denotes the solution to the matrix equation XA = B.<br />
    43. 43. Hands on Session: S2C5<br />Solving Linear Equations<br />The coefficient matrix A need not be square. If A is m-by-n, there are three cases: <br />m = n Square system. Seek an exact solution.<br />m > n Overdetermined system. Find a least squares solution.<br />m < n Underdetermined system. Find a basic solution with at most m nonzero components.<br />%% MATRIX Generations - 1<br />A=[2 4 5; 1 3 5; 3 1 6];<br />X=[2 5 7]';<br />B=A*X; %AX = B <br />%% Solution -1<br />Y = AB; % Standard Backslash operator used to solve the equation.<br />
    44. 44. Other useful stuffs<br />Logical Subscripting: The logical vectors created from logical and relational operations can be used to reference subarrays.<br />Suppose X is an ordinary matrix and L is a matrix of the same size that is the result of some logical operation. Then X(L) specifies the elements of X where the elements of L are nonzero.<br />Find: The find function determines the indices of array elements that meet a given logical condition.<br />Format: format long, format short e, format bank, format rat, format hex. <br />
    45. 45. Hands on Session S2C6<br />A=1:1000;<br />B=find(isprime(A))';<br />A=A(isprime(A));<br />scatter(B,A);<br />
    46. 46. Plotting Graphs using MATLAB<br />The MATLAB environment provides a wide variety of techniques to display data graphically.<br />Interactive tools enable you to manipulate graphs to achieve results that reveal the most information about your data.<br />You can also annotate and print graphs for presentations, or export graphs to standard graphics formats for presentation in Web browsers or other media<br />
    47. 47. Creating a graph <br />The type of graph you choose to create depends on the nature of your data and what you want to reveal about the data.<br />You can choose from many predefined graph types, such as line, bar, histogram, and pie graphs as well as 3-D graphs, such as surfaces, slice planes, and streamlines.<br />There are two basic ways to create MATLAB graphs:<br />Plotting tools to create graph interactively<br />Using CLI<br />
    48. 48. Other Aspects<br />Exploring Data<br />Editing the Graph component<br />Annotating graphs<br />Printing and exporting Graphs<br />Adding and removing figure content<br />Saving graphs for reuse<br />FIG File<br />Generated Codes<br />
    49. 49. Graph Components<br />MATLAB graphs display in a special window known as a figure.<br />Therefore, every graph is placed within axes defining a co-ordinate system, which are contained by the figure.<br />You achieve the actual visual representation of the data with graphics objects like lines and surfaces.<br />
    50. 50. A Basic Graph<br />
    51. 51. GUI for plotting Graphs<br />Type plottoolsin the command window.<br />The plotting tools are made up of three independent GUI components:<br />Figure Palette<br />Plot Browser<br />Property Editor<br />Visibility of these can be controlled from view menu. <br />
    52. 52. GUI for plotting graph<br />
    53. 53. Hands on S2C7<br />This graph contains two y-axis, one for each plot – a lineseries and a stemseries.<br />Demonstrate<br />Editing basic properties<br />Subplots<br />Various types of graph<br />Editing Plot in depth using property editor<br />Property Inspector<br />Multiple plots<br />Changing current plot types<br />Changing data source<br />Annotating Graph<br />Exporting graph<br />Generating M-Code<br />
    54. 54. Using Basic Plotting functions<br />Creating a Line graph<br />Plot(y) produces a piecewise linear graph of the elements of y versus the index of the elements of y. <br />Plot(x,y) produces a graph of y versus x. <br />Plot(x,y,x,y2,x,y3) produces multiple graph in the same figure with different colors. <br />It is possible to specify color, line-style and using plot command.<br />plot(x,y,'color_style_marker')<br />If Z is complex, plot(z) plots imag(z) vs real(z)<br />
    55. 55. Using basic Plotting functions<br />
    56. 56. Using basic Plotting functions<br />
    57. 57. Figure<br />Use hold on to plot more than 1 plot in same figure <br />Graphing functions automatically open a new figure window if there are no figure windows already on the screen.<br />To make an existing figure window the current figure, you can click the mouse while the pointer is in that window or you can type<br />Figure(n)<br />Clf reset<br />
    58. 58. Subplots<br />The subplot command enables you to display multiple plots in the same window or print them on the same piece of paper. <br />subplot(m,n,p)<br />partitions the figure window into an m-by-n matrix of small subplots and selects the pth subplot for the current plot. The plots are numbered along the first row of the figure window, then the second row, and so on.<br />
    59. 59. Controlling the Axis<br />The axis command provides a number of options for setting the scaling, orientation, and aspect ratio of graphs.<br />Setting Axis Limits<br />axis([xminxmaxyminymax])<br />Setting the Axis Aspect Ratio<br />axis square<br />axis equal<br />axis auto normal<br />
    60. 60. Hands on S2C8<br />
    61. 61. Control Flow<br />Conditional Control — if, else, switch<br />switch and case<br />For<br />While<br />Continu<br />Break<br />Error Control — try - catch – Advanced sessions<br />Program Termination — return<br />
    62. 62. Conditional Statements<br />A==B<br />An error when A and B not of same size. <br />If(isequal(A,B))<br />Returns a logical value of 1 (representing true) or 0(representing False), instead of a matrix.<br />Isempty<br />All<br />any<br />
    63. 63. Hands on S2C9<br />Explains matrix comparison complexities. <br />
    64. 64. Switch and Case<br />switch (rem(n,4)==0) + (rem(n,2)==0)<br /> case 0<br /> M = odd_magic(n)<br /> case 1<br /> M = single_even_magic(n)<br /> case 2<br /> M = double_even_magic(n)<br /> otherwise<br /> error('This is impossible')<br />End<br />Break Statements are not required.<br />
    65. 65. For Loops<br />If you can replace for loops with colon operator, this will increase the efficiency of you code in MATLAB. <br />All for loops cannot be replaced with colon operator. <br />It depends on whether the functions used in the given scenario accepts and operates on MATRIX data types<br />Efficiency tips: Do not let the size of your matrix grow inside a loop. Better is to pre-allocate the desired size using matrix generator functions like zeros, ones etc<br />
    66. 66. Hands on S2C10<br />
    67. 67. While loops<br />Continue statement<br />Break Statement<br />
    68. 68. Return Statements<br />Return function that enables you to terminate your program before it runs to completion.<br />A called function normally transfers control to the function that invoked it when it reaches the end of the function. You can insert a return statement within the called function to force an early termination and to transfer control to the invoking function.<br />
    69. 69. Other Data Structure<br />Multidimensional Arrays<br />Cell Arrays<br />Structures<br />
    70. 70. Multi-Dimensional Arrays<br />Multidimensional arrays in the MATLAB environment are arrays with more than two subscripts.<br />One way of creating a multidimensional array is by calling zeros, ones, rand, or randn with more than two arguments.<br />A three-dimensional array might represent three-dimensional physical data, say the temperature in a room, sampled on a rectangular grid.<br />Sum(m,d) – computes the sum by varying the dth subscript. <br />
    71. 71. 3-D Matrix<br />
    72. 72. Cell Arrays<br />Cell arrays in MATLAB are multidimensional arrays whose elements are copies of other arrays.<br />The cell function<br />But, more often, cell arrays are created by enclosing a miscellaneous collection of things in curly braces, {}.<br />To retrieve the contents of one of the cells, use subscripts in curly braces. <br />Second, cell arrays contain copies of other arrays, not pointers to those arrays. If you subsequently change A, nothing happens to C.<br />
    73. 73. Hands on S2C11<br />You can use three-dimensional arrays to store a sequence of matrices of the same size.<br />Cell arrays can be used to store a sequence of matrices of different sizes.<br />
    74. 74. The Magic Cell<br />
    75. 75. Character and Text<br />Strings is stored as character arrays in MATLAB. <br />The characters are stored as numbers, but not in floating-point format.<br />a=double(‘hello’)<br />B=char(a)<br />F = reshape(32:127,16,6)';<br />char(F)<br />
    76. 76. Character and string<br />Concatenation <br />Row wise<br />Column wise using char function<br />As a cell array – cellstr(S)<br />
    77. 77. Structures<br />Structures are multidimensional MATLAB arrays with elements accessed by textual field designators.<br />Field names of structures can be dynamic, and is evaluated during the runtime. Thus you can replace field names with other variables. <br />structName.(expression)<br />
    78. 78. Hands on S2C12<br />
    79. 79. Scripts and functions<br />Scripts – Collection of CLI commands<br />Declaration of functions<br />Nargin<br />Nargout<br />Eval function<br />
    80. 80. MATLAB Scripts<br />You can enter commands from the language one at a time at the MATLAB command line.<br />Or, you can write a series of commands to a file that you then execute as you would any MATLAB function.<br />All the scripts given to you are actually MATLAB scripts and could be directly called my writing their name of the file in the command window if the folder is included in the path.<br />Use the MATLAB Editor or any other text editor to create your own function files. Call these functions as you would any other MATLAB function or command.<br />
    81. 81. MATLAB Program files<br />There are two kinds of program files:<br />Scripts, which do not accept input arguments or return output arguments. They operate on data in the workspace.<br />Functions: which can accept input arguments and return output arguments. Internal variables are local to the function eg quadratic function we created yesterday. <br />If you duplicate function names, MATLAB executes the one that occurs first in the search path.<br />To view the contents of a program file, for example, myfunction.m, use<br />type myfunction<br />
    82. 82. Functions<br />Functions are files that can accept input arguments and return output arguments.<br />The names of the file and of the function should be the same.<br />Functions operate on variables within their own workspace, separate from the workspace you access at the MATLAB command prompt.<br />type rank<br />
    83. 83. MATLAB Functions<br />The first line of a function starts with the keyword function.<br />It gives the function name and order of arguments.<br />The next several lines, up to the first blank or executable line, are comment lines that provide the help text. These lines are printed when you type<br />help rank<br />
    84. 84. MATLAB Functions<br />MATLAB functions can have variable number of arguments not ordinarily found in other language. <br />If no output argument is supplied, the result is stored in ans.<br />Within the body of the function, two quantities named nargin and nargout are available that tell you the number of input and output arguments involved in each particular use of the function.<br />
    85. 85. Primary and Subfunctions<br />function file contains a required primary function that appears first, and any number of subfunctions that may follow the primary. Primary functions havea wider scope than subfunctions.<br />That is, primary functions can be called from outside of the file that defines them (e.g., from the MATLAB command line or from functions in other files) while subfunctions cannot. <br />Subfunctions are visible only to the primary function and other subfunctions within their own file.<br />
    86. 86. Private Functions<br />A private function is a type of primary function. Its unique characteristic is that it is visible only to a limited group of other functions. This type of function can be useful if you want to limit access to a function, or when you choose not to expose the implementation of a function.<br />Private functions reside in subfolders with the special name private. They are visible only to functions in the parent folder. For example, assume the folder newmath is on the MATLAB search path. A subfolder of newmath called private can contain functions that only the functions in newmath can call.<br />
    87. 87. Nested Functions<br />You can define functions within the body of another function. These are said to be nested within the outer function. A nested function contains any or all of the components of any other function.<br />In this example, function B is nested in function A:<br />function x = A(p1, p2)<br /> ...<br /> B(p2)<br /> function y = B(p3)<br /> ...<br /> end<br /> ...<br />end<br />
    88. 88. Nested Functions<br />Like other functions, a nested function has its own workspace where variables used by the function are stored. But it also has access to the workspaces of all functions in which it is nested.<br />So, for example, a variable that has a value assigned to it by the primary function can be read or overwritten by a function nested at any level within the primary. <br />Similarly, a variable that is assigned in a nested function can be read or overwritten by any of the functions containing that function.<br />
    89. 89. Function Overloading<br />Overloaded functions are useful when you need to create a function that responds to different types of inputs accordingly.<br />You can make this difference invisible to the user by creating two separate functions having the same name, and designating one to handle double types and one to handle integers. (more details on advanced session)<br />
    90. 90. Global Variables<br />If you want more than one function to share a single copy of a variable, simply declare the variable as global in all the functions.<br />Do the same thing at the command line if you want the base workspace to access the variable.<br />The global declaration must occur before the variable is actually used in a function.<br />
    91. 91. String Arguments to functions<br />You can write MATLAB functions that accept string arguments without the parentheses and quotes. That is, MATLAB interprets<br />foo a b c<br />as<br />foo('a','b','c')<br />
    92. 92. The eval function<br />The eval function works with text variables to implement a powerful text macro facility. The expression or statement. The expression or statement<br />eval(s)<br />uses the MATLAB interpreter to evaluate the expression or execute the statement contained in the text string s.<br />
    93. 93. The Function Handle<br />You can create a handle to any MATLAB function and then use that handle as a means of referencing the function.<br />A function handle is typically passed in an argument list to other functions, which can then execute, or evaluate, the function using the handle.<br />Construct a function handle in MATLAB using the at sign, @, before the function name.<br />fhandle = @sin;<br />
    94. 94. The Function Handle<br />You can call a function by means of its handle in the same way that you would call the function using its name.<br />
    95. 95. Hands on Session S2C13 – fun_plot<br />
    96. 96. We have covered bases<br />We will now move on to some engineering application of MATLAB before covering some advanced topics. <br />End of Session 2<br />?<br />Ask Questions for the sake of those sitting around you.<br />
    97. 97. Mayank Kumar<br />IDEAS2IGNITE<br />