matlab
play

MATLAB 1 Mathematical Software Symbolic Math Packages - This - PowerPoint PPT Presentation

MATLAB 1 Mathematical Software Symbolic Math Packages - This amorphous set of packages can be used to perform symbolic analyses. These packages typically can solve algebraic and differential equations, can integrate and differentiate


  1. MATLAB 1

  2. Mathematical Software • Symbolic Math Packages - This amorphous set of packages can be used to perform symbolic analyses. These packages typically can solve algebraic and differential equations, can integrate and differentiate symbolic expressions, and can simplify and manipulate algebraic expressions. • Maple - Produced by Waterloo Maple Inc., in Canada. It is somewhat smaller than its competitors, but is as powerful as any package available. The syntax for this package is relatively intuitive for mathematicians. It has relatively powerful typesetting capabilities. • Mathematica - Produced by Wolfram Inc., in the U.S.. The syntax for this package is less intuitive than that for some, but is arguably more consistent. The package is as powerful as any available, but tends to require more memory than some of its competitors. It also has powerful typesetting abilities. • Macsyma - This was the first symbolic mathematics package, dating from the early 1980s, and produced at MIT. It is now free, and is available for many platforms. Unfortunately, it suffers from perhaps the most obscure syntax of any package of its kind, and has relatively poor graphics. • Sympy , Sage , etc. - There are several packages for use in python that can do symbolic mathematics. • Numerical Packages - packages in this class excel at solving numerical problems. While some have limited symbolic capabilities, they are best when programmed to run complicated algorithms. They can handle all problems involving numerical matrices and vectors. • Matlab - produced by the Mathworks in the U.S., this is the gold standard of the class of packages. It is probably the most-used mathematical package for both mathematicians and engineers. For a price, it can have some symbolic capability. • Octave - this package is free, and does most of what Matlab does. While it lacks the symbolic toolbox and several other add-on features of Matlab, and its graphics are not of the same standard, in the end it is an excellent and powerful free alternative, available for most platforms. • Numpy , Scipy , Matplotlib , Pylab etc .- There are several related packages for python that can mimic the numerical and plotting capabilities of Matlab. • R, Stata, SPSS – These are numerical software pacakges specialized primarily for statistical computing. • Mathematical spreadsheets - we are aware of only one program in this class, used more by scientists and engineers than by mathematicians. It is called Mathcad. It is not really a spreadsheet, but we refer to it that way because the position of expressions on a page determines their order of execution. It has some symbolic capability, but it is best at doing analyses that involve changing a parameter and running a sequence of calculations anew. 2

  3. MATLAB • MATLAB is a multi-paradigm (functional, imperative, procedural, object-oriented) numerical computing environment and programming language. A proprietary programming language developed by MathWorks , MATLAB allows matrix manipulations, plotting of functions and data, implementation of algorithms, creation of user interfaces, and interfacing with programs written in other languages, including C, C++, C#, Java, Fortran and Python. • The program MATLAB dates from the mid-1980s. It came out of work by Cleve Moler , who remains the head of MathWorks. It was designed with relatively humble objectives: to provide a simple interface to high-quality numerical procedures for solving mathematical problems written in Fortran. Indeed, MATLAB stands for Matrix Laboratory. It has effectively become the standard package for mathematicians and engineers who need to do quick-and-dirty estimates, simulations, designs, and tests of algorithms. • Although MATLAB is intended primarily for numerical computing, an optional toolbox uses a symbolic engine called MuPAD , allowing access to symbolic computing abilities. 3

  4. MATLAB Basics • When you start MATLAB, regardless of the details of the interface, you should notice immediately that it is basically just a command line . You type commands, hit <Enter>, and the commands are executed. The basic syntax is very natural to anyone who has used a computer before. For example, to do a simple arithmetic calculation, just type it in and press <Enter>. >> 3+4 ans = 7 • This illustrates several basic notions behind Matlab. First, Matlab can do all basic arithmetic operations with a very natural syntax. Second, Matlab requires that every computation be assigned to a variable . • As well as in Linux or Windows shell all commands are executed in the context of a certain environment. In MATLAB such environment called the Workspace . If you are running MATLAB in graphical mode, by default you should see the Workspace panel on the right. 4

  5. MATLAB Basics • If you do not specify the name of the variable, MATLAB uses a default name: ans . MATLAB reuses the name ans as needed, so if you want to keep the result of a computation for reference later in a session, you should assign it to a different variable. For example, the following just assigns the value 7 to a variable called seven : >> seven=3+4 seven = 7 • Every time a new variable is assigned, MATLAB adds it to the workspace so it can be accessed any time later. We may view the contents of the variable seven at any time simply by typing its name: >> seven seven = 7 • One may use variables interchangeably with the numbers or objects that they represent. For example, we could define a variable called ten by >> ten=seven+3 ten = 10 • Matlab uses “+” to denote addition, “-” to denote subtrac�on, “*” for mul�plica�on, “/” for division, and “ˆ” to denote exponentiation: >> myvariable=2*(ten-2)+(ten/5)^2 myvariable = 20 5

  6. MATLAB Basics: Identifier Names • Variable names are examples of identifier names . The rules for identifier names are as follows: 1. The name must begin with a letter of the alphabet . After that, the name can contain letters, digits, and the underscore character (e.g., value_1 ), but it cannot have a space. There is a limit to the length of the name ; the built-in function namelengthmax tells 2. what this maximum length is (any extra characters are truncated). 3. MATLAB is case-sensitive , which means that there is a difference between upper- and lowercase letters. So, variables called mynum , MYNUM , and Mynum are all different (although this would be confusing and should not be done). 4. Although underscore characters are valid in a name, their use can cause problems with some programs that interact with MATLAB, so some programmers use mixed case instead (e.g., partWeights instead of part_weights ). 5. There are certain words called reserved words , or keywords , that cannot be used as variable names. 6. Names of built-in functions can, but should not, be used as variable names. • Obviously, variable names should always be mnemonic , which means that they should make some sense. For example, if the variable is storing the radius of a circle, a name such as radius would make sense; x probably wouldn’t. 6

  7. MATLAB Basics: Variables • The following commands relate to variables:  who – shows variables that have been defined in this Command Window (this just shows the names of the variables)  whos – shows variables that have been defined in this Command Window (this shows more information on the variables, similar to what is in the Workspace Window)  clear – clears out all variables so they no longer exist  clear variablename – clears out a particular variable  clear variablename1 variablename2 – clears out a list of variables (note: separate the names with spaces) • Note that to suppress automatic output of the result of particular command one should add semicolon at the end of this command. 7

  8. MATLAB Basics: Data Types • Every variable has a type associated with it. MATLAB supports many types, which are called classes . Essentially, a class is a combination of a type and the operations that can be performed on values of that type. Note that different classes may have the same operations define but the result of applying them may be different. • Users can define their own custom types/classes . • Note that MATLAB has dynamic typing , which means that type of variable is inferred automatically and you may not specify it explicitly. • To force MATLAB to assign specific type to a variable one can use the following syntax variablename = typename(variablevalue) • To see what class is assigned to a particular variable one can use class(variablename) command. 8

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend