All You Really Need to Know about MATLAB (at least for ENCE 201)

Size: px
Start display at page:

Download "All You Really Need to Know about MATLAB (at least for ENCE 201)"

Transcription

1 All You Really Need to Know about MATLAB (at least for ENCE 201) Charles W. Schwartz August 2004 The purpose of these notes is to give you a bare bones summary of the subset of MATLAB features that will be most useful for the programming exercises in ENCE 201. MATLAB is a very powerful computational tool that offers a wealth of features beyond those described here. You should consult the MATLAB documentation and Demonstration programs for an overview of these additional advanced features. DOCUMENTATION For details (syntax, usage, etc.) and information on more advanced MATLAB features Help menu from main MATLAB window Online at http// Other useful information Demos from MATLAB Start button Getting Started section online, accessible via link from page http// DATA TYPES By default, all constant and variables in MATLAB are double precision floating point. All computations are also performed in double precision by default. Double precision floating-point numbers in MATLAB have a finite precision of roughly 16 significant decimal digits and a finite range of roughly to VARIABLES Variable names consist of a letter, followed by any number of letters, digits, or underscores. MATLAB uses only the first 31 characters of a variable name. MATLAB is case sensitive; it distinguishes between uppercase and lowercase letters. A and a are not the same variable. To view the value(s) assigned to any variable, simply enter the variable name in the Command window. MATRICES A matrix is entered as a list of its elements following a few basic conventions Separate the elements of a row with blanks or commas. Use a semicolon, ;, to indicate the of each row. Surround the entire list of elements with square brackets, [ ]. 1

2 For example, type in the Command window A = [ ; ; ; ] MATLAB displays the matrix you just entered A = The element in row i and column j of A is denoted by A(i,j). If you try to use the value of an element outside of the matrix, it is an error. On the other hand, if you store a value in an element outside of the matrix, the size increases automatically to accommodate the new element. A scalar is equivalent to a 1x1 matrix. In this case, the square brackets are not required A = 16 OPERATORS Arithmetic Operators Expressions use familiar arithmetic operators and precedence rules. + Addition - Subtraction * Multiplication / Division \ Left division (see "Matrices and Linear Algebra" in MATLAB ^ Power ( ) Specify evaluation order Matrix Operators + Addition - Subtraction * Matrix multiplication Transpose (e.g., A ) inv(a) Matrix inverse det(a) Matrix determinant ( ) Specify evaluation order 2

3 Relational Operators Operator Description < Less than <= Less than or equal to > Greater than >= Greater than or equal to == Equal to ~= Not equal to Logical Operators Operator Description & And Or ~ Not Colon Operator The colon,, is an important operator specific to MATLAB. It occurs in several different forms. The expression 110 is a row vector containing the integers from 1 to To obtain non-unit spacing, specify an increment. For example, is Subscript expressions involving colons refer to portions of a matrix. A(1k,j) is the first k elements of the jth column of A. STATEMENTS AND EXPRESSIONS Arithmetic expressions are written and evaluated in MATLAB much the same as they are in Excel. An example of a MATLAB statement that assigns the result of an arithmetic expression to the variable rho rho = (1+sqrt(5))/2 rho =

4 Matrices and scalars can be combined in expressions. For example, a scalar is subtracted from a matrix by subtracting it from each element B = A B = for the matrix A given earlier under the MATRICES section. If you simply type a statement and press Return or Enter, MATLAB automatically displays the results on screen. However, if you the line with a semicolon, MATLAB performs the computation but does not display any output. If a statement does not fit on one line, use an ellipsis (three periods),..., followed by Return or Enter to indicate that the statement continues on the next line. For example, s = 1-1/2 + 1/3-1/4 + 1/5-1/6 + 1/ /8 + 1/9-1/10 + 1/11-1/12; Blank spaces around the =, +, and - signs are optional, but they improve readability. BUILT-IN FUNCTIONS MATLAB provides a large number of standard elementary mathematical functions. MATLAB also provides many more advanced mathematical functions. For a list of the elementary mathematical functions, type help elfun For a list of more advanced mathematical and matrix functions, type help specfun help elmat Several special functions provide values of useful constants. pi eps Floating-point relative precision, 2-52 realmin Smallest floating-point number, realmax Largest floating-point number, (2-) Inf Infinity NaN../../techd Not-a-number INPUT/OUTPUT Console I/O (i.e., Keyboard and Screen) Keyboard Input The input function displays a prompt and waits for a user response. Its syntax is 4

5 n = input('prompt_string') The function displays the prompt_string, waits for keyboard input, and then returns the value from the keyboard. If the user inputs an expression, the function evaluates it and returns its value. Pausing Execution Some M-files benefit from pauses between execution steps. The pause command, with no arguments, stops execution until the user presses a key. To pause for n seconds, use pause(n) Screen Output disp(x) displays an array, without printing the array name. If X contains a text string, the string is displayed. Another way to display an array on the screen is to type its name, but this prints a leading "X =," which is not always desirable. For example, use disp in an M-file is to display a matrix with column labels disp(' Corn Oats Hay') disp(rand(5,3)) which results in Corn Oats Hay (See also format and sprintf for screen output with greater format control.) File I/O The load function text files containing numeric data. The text file should be organized as a rectangular table of numbers, separated by blanks, with one row per line, and an equal number of elements in each row. For example, create a text file (e.g., using the Windows Notepad editor) containing these four lines Store the file under the name magik.dat. Then the statement load magik.dat reads the file and creates a variable, magik, containing the example matrix. For more powerful file input/output capabilities (i.e., different file structures, binary files, etc.) see the Programming and Data Types..Input/Output in the online MATLAB documentation at http// 5

6 FLOW CONTROL The most useful flow control constructs in MATLAB are if..elseif..else.. switch..case for while continue break if..elseif..else.. The if statement evaluates a logical expression and executes a group of statements based on the value of the expression. In its simplest form, its syntax is if logical_expression statements If the logical expression is true (1), MATLAB executes all the statements between the if and lines and then continues execution at the line following the statement. If the condition is false (0), MATLAB skips all the statements between the if and lines, and resumes execution at the line following the statement. For example if rem(a,2) == 0 disp('a is even') b = a/2; You can nest any number of if statements. It is a good idea to indent the statement blocks for readability, especially when using nested if statements. The optional elseif and else keywords ext the basic if.. construction and enables execution of alternate groups of statements if logical_expression_1 statements executed if logical_expression_1 = true elseif logical_expression_2 statements executed if logical_expression_2 = true else statement executed if none of the above is true Note that at most only one statement block is executed with this construction (i.e., the first elseif statement block for which the associated logical_expression is true, or the else statement block, if present). 6

7 switch..case The switch construction executes certain statements based on the value of a variable or expression. Its basic form is switch expression case value1 statements % Executes if expression is value1 case value2 statements % Executes if expression is value2... otherwise statements % Executes if expression does not % does not match any case It is a good idea to indent the statement blocks for readability. The example code below shows use of the switch statement to check the variable input_num for certain values. If input_num is -1, 0, or 1, the case statements display the value on screen as text. If input_num is none of these values, execution drops to the otherwise statement and the code displays the text 'other value'. switch input_num case -1 disp('negative one'); case 0 disp('zero'); case 1 disp('positive one'); otherwise disp('other value'); Note Unlike the C language switch statement, MATLAB switch does not fall through. If the first case statement is true, the other case statements do not execute. So, break statements are not required. switch can handle multiple conditions in a single case statement by enclosing the case expression in a cell array. switch var case 1 disp('1') case {2,3,4} disp('2 or 3 or 4') case 5 disp('5') otherwise disp('something else') 7

8 for The for loop executes a statement or group of statements a predetermined number of times. Its syntax is for index = startincrement statements The default increment is 1. You can specify any increment, including a negative one. For positive indices, execution terminates when the value of the index exceeds the value; for negative increments, it terminates when the index is less than the value. For example, this loop executes five times. for i = 26 x(i) = 2*x(i-1); You can nest multiple for loops. for i = 1m for j = 1n A(i,j) = 1/(i + j - 1); It is a good idea to indent the loops for readability, especially when they are nested. while The while loop executes a statement or group of statements repeatedly as long as the controlling expression is true (1). Its syntax is while expression statements For example, this while loop finds the first integer n for which n! (n factorial) is a 100-digit number. n = 1; while prod(1n) < 1e100 n = n + 1; n Exit a while loop at any time using the break statement continue The continue statement passes control to the next iteration of the for or while loop in which it appears, skipping any remaining statements in the body of the loop. In nested loops, continue passes control to the next iteration of the for or while loop enclosing it. 8

9 break The break statement terminates the execution of a for loop or while loop. When a break statement is encountered, execution continues with the next statement outside of the loop. In nested loops, break exits from the innermost loop only. GRAPHICS MATLAB has a rich set of built-in functions for creating graphic displays of data and functions. See the Graphics section in the online Getting Started documentation at http// for usage of these graphics features. M-FILES There are two kinds of M-files. Script M-Files Do not accept input arguments or return output arguments Operate on data in the workspace Useful for automating a series of steps you need to perform many times Function M-Files Can accept input arguments and return output arguments Internal variables are local to the function by default Useful for exting the MATLAB language for your application M-files are ordinary text files that you create using a text editor. MATLAB provides a built-in editor, although you can use any text editor you like. Comment lines begin with a percent sign (%). Comment lines can appear anywhere in an M-file, and you can app comments to the of a line of code. For example, % Add up all the vector elements. y = sum(x) % Use the built-in sum function. In addition to comment lines, you can insert blank lines anywhere in an M-file. MATLAB uses a search path to find M-files and other MATLAB-related files. Any file you want to run in MATLAB must reside in the current directory or in a directory that is on the search path. To see which directories are on the search path or to change the search path, select Set Path from the File menu in the desktop, and use the Set Path dialog box. Scripts Scripts are useful for automating series of MATLAB commands, such as computations that you have to perform repeatedly from the command line. They are the simplest kind of M-file because they have no input or output arguments. Scripts operate on existing data in the workspace, or they 9

10 can create new data on which to operate. Any variables that scripts create remain in the workspace after the script finishes so you can use them for further computations. For example, these statements calculate rho for several trigonometric functions of theta, then create a series of polar plots. % An M-file script to produce % Comment lines % "flower petal" plots theta = -pi0.01pi; % Computations rho(1,) = 2*sin(5*theta).^2; rho(2,) = cos(10*theta).^3; rho(3,) = sin(theta).^2; rho(4,) = 5*cos(3.5*theta).^3; for k = 14 polar(theta,rho(k,)) % Graphics output pause These lines can be saved as a script in an M-file called petals.m. Typing petals at the MATLAB command line executes the statements in the script. After the script displays a plot, press Return to move to the next plot. When execution completes, the variables (i, theta, and rho) remain in the workspace. To see a listing of them, enter whos at the command prompt. Functions Functions are M-files that accept input arguments and return output arguments. They operate on variables within their own workspace. This is separate from the workspace you access at the MATLAB command prompt. For example, the following function calculates the average of the elements in a vector. function y = average(x) % AVERAGE Mean of vector elements. % AVERAGE(X), where X is a vector, is the mean of vector elements. % Nonvector input results in an error. [m,n] = size(x); if (m==1 & n>1) (m>1 & n==1) y = sum(x)/length(x); %actual computation else %error--input not a vector error('input must be a vector') These commands are stored in an M-file called average.m. The average function accepts a single input argument and returns a single output argument. To call the average function, enter z = 199; average(z) ans = 50 10

11 The function definition line informs MATLAB that the M-file contains a function, and specifies the argument calling sequence of the function. The function definition line for the average function is Note While the function name specified on the function definition line does not have to be the same as the filename, it is strongly recommed that you use the same name for both. If the function has multiple output values, enclose the output argument list in square brackets. Input arguments, if present, are enclosed in parentheses. Use commas to separate multiple input or output arguments. Here's a more complicated example. function [x, y, z] = sphere(theta, phi, rho) If there is no output, leave the output blank function printresults(x) or use empty square brackets function [] = printresults(x) The variables that you pass to the function do not need to have the same name as those in the function definition line. The function body contains all the MATLAB code that performs computations and assigns values to output arguments. The statements in the function body can consist of function calls, programming constructs like flow control and interactive input/output, calculations, assignments, comments, and blank lines. The values of all local variables within a function are cleared from memory after the function has been exited unless they are explicitly declared persistent. You can call function M-files from either the MATLAB command line or from within other M- files. Be sure to include all necessary arguments, enclosing input arguments in parentheses and output arguments in square brackets. Subfunctions Function M-files can contain code for more than one function. The first function in the file is the primary function, the function invoked with the M-file name. Additional functions within the file are subfunctions that are only visible to the primary function or other subfunctions in the same file. Each subfunction begins with its own function definition line. The functions immediately follow each other. The various subfunctions can occur in any order, as long as the primary function appears first. 11

12 function [avg,med] = newstats(u) % Primary function % NEWSTATS Find mean and median with internal functions. n = length(u); avg = mean(u,n); med = median(u,n); function a = mean(v,n) % Calculate average. a = sum(v)/n; % Subfunction function m = median(v,n) % Calculate median. w = sort(v); if rem(n,2) == 1 m = w((n+1)/2); else m = (w(n/2)+w(n/2+1))/2; % Subfunction Functions within the same M-file cannot access the same variables unless you declare them as global within the pertinent functions (global declaration) or pass them as arguments. return The return statement terminates the current sequence of commands and returns control to the invoking function. A called function normally transfers control to the function that invoked it when it reaches the of the function. return may be inserted within the called function to force an early termination and to transfer control to the invoking function. 12

Introduction to Matlab

Introduction to Matlab Introduction to Matlab Social Science Research Lab American University, Washington, D.C. Web. www.american.edu/provost/ctrl/pclabs.cfm Tel. x3862 Email. SSRL@American.edu Course Objective This course provides

More information

AMATH 352 Lecture 3 MATLAB Tutorial Starting MATLAB Entering Variables

AMATH 352 Lecture 3 MATLAB Tutorial Starting MATLAB Entering Variables AMATH 352 Lecture 3 MATLAB Tutorial MATLAB (short for MATrix LABoratory) is a very useful piece of software for numerical analysis. It provides an environment for computation and the visualization. Learning

More information

MATLAB Basics MATLAB numbers and numeric formats

MATLAB Basics MATLAB numbers and numeric formats MATLAB Basics MATLAB numbers and numeric formats All numerical variables are stored in MATLAB in double precision floating-point form. (In fact it is possible to force some variables to be of other types

More information

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program. Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to

More information

(!' ) "' # "*# "!(!' +,

(!' ) ' # *# !(!' +, MATLAB is a numeric computation software for engineering and scientific calculations. The name MATLAB stands for MATRIX LABORATORY. MATLAB is primarily a tool for matrix computations. It was developed

More information

MATLAB Programming. Problem 1: Sequential

MATLAB Programming. Problem 1: Sequential Division of Engineering Fundamentals, Copyright 1999 by J.C. Malzahn Kampe 1 / 21 MATLAB Programming When we use the phrase computer solution, it should be understood that a computer will only follow directions;

More information

Beginning Matlab Exercises

Beginning Matlab Exercises Beginning Matlab Exercises R. J. Braun Department of Mathematical Sciences University of Delaware 1 Introduction This collection of exercises is inted to help you start learning Matlab. Matlab is a huge

More information

Appendix: Tutorial Introduction to MATLAB

Appendix: Tutorial Introduction to MATLAB Resampling Stats in MATLAB 1 This document is an excerpt from Resampling Stats in MATLAB Daniel T. Kaplan Copyright (c) 1999 by Daniel T. Kaplan, All Rights Reserved This document differs from the published

More information

Beginner s Matlab Tutorial

Beginner s Matlab Tutorial Christopher Lum lum@u.washington.edu Introduction Beginner s Matlab Tutorial This document is designed to act as a tutorial for an individual who has had no prior experience with Matlab. For any questions

More information

2+2 Just type and press enter and the answer comes up ans = 4

2+2 Just type and press enter and the answer comes up ans = 4 Demonstration Red text = commands entered in the command window Black text = Matlab responses Blue text = comments 2+2 Just type and press enter and the answer comes up 4 sin(4)^2.5728 The elementary functions

More information

Introduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved.

Introduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved. 1 2 Introduction to Java Applications 2.2 First Program in Java: Printing a Line of Text 2 Application Executes when you use the java command to launch the Java Virtual Machine (JVM) Sample program Displays

More information

Sources: On the Web: Slides will be available on:

Sources: On the Web: Slides will be available on: C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,

More information

JavaScript: Introduction to Scripting. 2008 Pearson Education, Inc. All rights reserved.

JavaScript: Introduction to Scripting. 2008 Pearson Education, Inc. All rights reserved. 1 6 JavaScript: Introduction to Scripting 2 Comment is free, but facts are sacred. C. P. Scott The creditor hath a better memory than the debtor. James Howell When faced with a decision, I always ask,

More information

CD-ROM Appendix E: Matlab

CD-ROM Appendix E: Matlab CD-ROM Appendix E: Matlab Susan A. Fugett Matlab version 7 or 6.5 is a very powerful tool useful for many kinds of mathematical tasks. For the purposes of this text, however, Matlab 7 or 6.5 will be used

More information

2 Matlab Programming, IO, and strings

2 Matlab Programming, IO, and strings 2 Matlab Programming, IO, and strings Programming is the basic skill for implementing numerical methods. In this chapter we describe the fundamental programming constructs used in MATLAB and present examples

More information

Introduction to Python

Introduction to Python Caltech/LEAD Summer 2012 Computer Science Lecture 2: July 10, 2012 Introduction to Python The Python shell Outline Python as a calculator Arithmetic expressions Operator precedence Variables and assignment

More information

MATLAB Functions. function [Out_1,Out_2,,Out_N] = function_name(in_1,in_2,,in_m)

MATLAB Functions. function [Out_1,Out_2,,Out_N] = function_name(in_1,in_2,,in_m) MATLAB Functions What is a 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

More information

Linear Algebra and TI 89

Linear Algebra and TI 89 Linear Algebra and TI 89 Abdul Hassen and Jay Schiffman This short manual is a quick guide to the use of TI89 for Linear Algebra. We do this in two sections. In the first section, we will go over the editing

More information

MATLAB Workshop 3 - Vectors in MATLAB

MATLAB Workshop 3 - Vectors in MATLAB MATLAB: Workshop - Vectors in MATLAB page 1 MATLAB Workshop - Vectors in MATLAB Objectives: Learn about vector properties in MATLAB, methods to create row and column vectors, mathematical functions with

More information

Simple File Input & Output

Simple File Input & Output Simple File Input & Output Handout Eight Although we are looking at file I/O (Input/Output) rather late in this course, it is actually one of the most important features of any programming language. The

More information

MATLAB Primer. R2015b

MATLAB Primer. R2015b MATLAB Primer R25b How to Contact MathWorks Latest news: www.mathworks.com Sales and services: www.mathworks.com/sales_and_services User community: www.mathworks.com/matlabcentral Technical support: www.mathworks.com/support/contact_us

More information

Chapter One Introduction to Programming

Chapter One Introduction to Programming Chapter One Introduction to Programming 1-1 Algorithm and Flowchart Algorithm is a step-by-step procedure for calculation. More precisely, algorithm is an effective method expressed as a finite list of

More information

Data Tool Platform SQL Development Tools

Data Tool Platform SQL Development Tools Data Tool Platform SQL Development Tools ekapner Contents Setting SQL Development Preferences...5 Execution Plan View Options Preferences...5 General Preferences...5 Label Decorations Preferences...6

More information

Financial Econometrics MFE MATLAB Introduction. Kevin Sheppard University of Oxford

Financial Econometrics MFE MATLAB Introduction. Kevin Sheppard University of Oxford Financial Econometrics MFE MATLAB Introduction Kevin Sheppard University of Oxford October 21, 2013 2007-2013 Kevin Sheppard 2 Contents Introduction i 1 Getting Started 1 2 Basic Input and Operators 5

More information

Perl in a nutshell. First CGI Script and Perl. Creating a Link to a Script. print Function. Parsing Data 4/27/2009. First CGI Script and Perl

Perl in a nutshell. First CGI Script and Perl. Creating a Link to a Script. print Function. Parsing Data 4/27/2009. First CGI Script and Perl First CGI Script and Perl Perl in a nutshell Prof. Rasley shebang line tells the operating system where the Perl interpreter is located necessary on UNIX comment line ignored by the Perl interpreter End

More information

How long is the vector? >> length(x) >> d=size(x) % What are the entries in the matrix d?

How long is the vector? >> length(x) >> d=size(x) % What are the entries in the matrix d? MATLAB : A TUTORIAL 1. Creating vectors..................................... 2 2. Evaluating functions y = f(x), manipulating vectors. 4 3. Plotting............................................ 5 4. Miscellaneous

More information

Moving from CS 61A Scheme to CS 61B Java

Moving from CS 61A Scheme to CS 61B Java Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you

More information

GUI Input and Output. Greg Reese, Ph.D Research Computing Support Group Academic Technology Services Miami University

GUI Input and Output. Greg Reese, Ph.D Research Computing Support Group Academic Technology Services Miami University GUI Input and Output Greg Reese, Ph.D Research Computing Support Group Academic Technology Services Miami University GUI Input and Output 2010-13 Greg Reese. All rights reserved 2 Terminology User I/O

More information

Introduction. Chapter 1

Introduction. Chapter 1 Chapter 1 Introduction MATLAB (Matrix laboratory) is an interactive software system for numerical computations and graphics. As the name suggests, MATLAB is especially designed for matrix computations:

More information

Einführung in MATLAB Sommer Campus 2004

Einführung in MATLAB Sommer Campus 2004 Einführung in MATLAB Sommer Campus 2004 Teil I G.Brunner, B. Haasdonk, K. Peschke Lehrstuhl für Mustererkennung und Bildverarbeitung Uni Freiburg Seite 1 Einteilung des Kurses Teil 1 (Mittwoch) allgemeine

More information

u = [ 2 4 5] has one row with three components (a 3 v = [2 4 5] has three rows separated by semicolons (a 3 w = 2:5 generates the row vector w = [ 2 3

u = [ 2 4 5] has one row with three components (a 3 v = [2 4 5] has three rows separated by semicolons (a 3 w = 2:5 generates the row vector w = [ 2 3 MATLAB Tutorial You need a small numb e r of basic commands to start using MATLAB. This short tutorial describes those fundamental commands. You need to create vectors and matrices, to change them, and

More information

Simulation Tools. Python for MATLAB Users I. Claus Führer. Automn 2009. Claus Führer Simulation Tools Automn 2009 1 / 65

Simulation Tools. Python for MATLAB Users I. Claus Führer. Automn 2009. Claus Führer Simulation Tools Automn 2009 1 / 65 Simulation Tools Python for MATLAB Users I Claus Führer Automn 2009 Claus Führer Simulation Tools Automn 2009 1 / 65 1 Preface 2 Python vs Other Languages 3 Examples and Demo 4 Python Basics Basic Operations

More information

The Center for Teaching, Learning, & Technology

The Center for Teaching, Learning, & Technology The Center for Teaching, Learning, & Technology Instructional Technology Workshops Microsoft Excel 2010 Formulas and Charts Albert Robinson / Delwar Sayeed Faculty and Staff Development Programs Colston

More information

G563 Quantitative Paleontology. SQL databases. An introduction. Department of Geological Sciences Indiana University. (c) 2012, P.

G563 Quantitative Paleontology. SQL databases. An introduction. Department of Geological Sciences Indiana University. (c) 2012, P. SQL databases An introduction AMP: Apache, mysql, PHP This installations installs the Apache webserver, the PHP scripting language, and the mysql database on your computer: Apache: runs in the background

More information

Chapter 2: Elements of Java

Chapter 2: Elements of Java Chapter 2: Elements of Java Basic components of a Java program Primitive data types Arithmetic expressions Type casting. The String type (introduction) Basic I/O statements Importing packages. 1 Introduction

More information

Tutorial Program. 1. Basics

Tutorial Program. 1. Basics 1. Basics Working environment Dealing with matrices Useful functions Logical operators Saving and loading Data management Exercises 2. Programming Basics graphics settings - ex Functions & scripts Vectorization

More information

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement? 1. Distinguish & and && operators. PART-A Questions 2. How does an enumerated statement differ from a typedef statement? 3. What are the various members of a class? 4. Who can access the protected members

More information

I PUC - Computer Science. Practical s Syllabus. Contents

I PUC - Computer Science. Practical s Syllabus. Contents I PUC - Computer Science Practical s Syllabus Contents Topics 1 Overview Of a Computer 1.1 Introduction 1.2 Functional Components of a computer (Working of each unit) 1.3 Evolution Of Computers 1.4 Generations

More information

Database Programming with PL/SQL: Learning Objectives

Database Programming with PL/SQL: Learning Objectives Database Programming with PL/SQL: Learning Objectives This course covers PL/SQL, a procedural language extension to SQL. Through an innovative project-based approach, students learn procedural logic constructs

More information

Excel supplement: Chapter 7 Matrix and vector algebra

Excel supplement: Chapter 7 Matrix and vector algebra Excel supplement: Chapter 7 atrix and vector algebra any models in economics lead to large systems of linear equations. These problems are particularly suited for computers. The main purpose of this chapter

More information

AP Computer Science Java Mr. Clausen Program 9A, 9B

AP Computer Science Java Mr. Clausen Program 9A, 9B AP Computer Science Java Mr. Clausen Program 9A, 9B PROGRAM 9A I m_sort_of_searching (20 points now, 60 points when all parts are finished) The purpose of this project is to set up a program that will

More information

Microsoft Excel 2010 Part 3: Advanced Excel

Microsoft Excel 2010 Part 3: Advanced Excel CALIFORNIA STATE UNIVERSITY, LOS ANGELES INFORMATION TECHNOLOGY SERVICES Microsoft Excel 2010 Part 3: Advanced Excel Winter 2015, Version 1.0 Table of Contents Introduction...2 Sorting Data...2 Sorting

More information

VHDL Test Bench Tutorial

VHDL Test Bench Tutorial University of Pennsylvania Department of Electrical and Systems Engineering ESE171 - Digital Design Laboratory VHDL Test Bench Tutorial Purpose The goal of this tutorial is to demonstrate how to automate

More information

How to test and debug an ASP.NET application

How to test and debug an ASP.NET application Chapter 4 How to test and debug an ASP.NET application 113 4 How to test and debug an ASP.NET application If you ve done much programming, you know that testing and debugging are often the most difficult

More information

Exercise 4 Learning Python language fundamentals

Exercise 4 Learning Python language fundamentals Exercise 4 Learning Python language fundamentals Work with numbers Python can be used as a powerful calculator. Practicing math calculations in Python will help you not only perform these tasks, but also

More information

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T) Unit- I Introduction to c Language: C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating

More information

Creating a Simple Macro

Creating a Simple Macro 28 Creating a Simple Macro What Is a Macro?, 28-2 Terminology: three types of macros The Structure of a Simple Macro, 28-2 GMACRO and ENDMACRO, Template, Body of the macro Example of a Simple Macro, 28-4

More information

PTC Mathcad Prime 3.0 Keyboard Shortcuts

PTC Mathcad Prime 3.0 Keyboard Shortcuts PTC Mathcad Prime 3.0 Shortcuts Swedish s Regions Inserting Regions Operator/Command Description Shortcut Swedish Area Inserts a collapsible area you can collapse or expand to toggle the display of your

More information

VB.NET Programming Fundamentals

VB.NET Programming Fundamentals Chapter 3 Objectives Programming Fundamentals In this chapter, you will: Learn about the programming language Write a module definition Use variables and data types Compute with Write decision-making statements

More information

3.GETTING STARTED WITH ORACLE8i

3.GETTING STARTED WITH ORACLE8i Oracle For Beginners Page : 1 3.GETTING STARTED WITH ORACLE8i Creating a table Datatypes Displaying table definition using DESCRIBE Inserting rows into a table Selecting rows from a table Editing SQL buffer

More information

Computational Mathematics with Python

Computational Mathematics with Python Boolean Arrays Classes Computational Mathematics with Python Basics Olivier Verdier and Claus Führer 2009-03-24 Olivier Verdier and Claus Führer Computational Mathematics with Python 2009-03-24 1 / 40

More information

SYSTEMS OF EQUATIONS AND MATRICES WITH THE TI-89. by Joseph Collison

SYSTEMS OF EQUATIONS AND MATRICES WITH THE TI-89. by Joseph Collison SYSTEMS OF EQUATIONS AND MATRICES WITH THE TI-89 by Joseph Collison Copyright 2000 by Joseph Collison All rights reserved Reproduction or translation of any part of this work beyond that permitted by Sections

More information

arrays C Programming Language - Arrays

arrays C Programming Language - Arrays arrays So far, we have been using only scalar variables scalar meaning a variable with a single value But many things require a set of related values coordinates or vectors require 3 (or 2, or 4, or more)

More information

Excel: Introduction to Formulas

Excel: Introduction to Formulas Excel: Introduction to Formulas Table of Contents Formulas Arithmetic & Comparison Operators... 2 Text Concatenation... 2 Operator Precedence... 2 UPPER, LOWER, PROPER and TRIM... 3 & (Ampersand)... 4

More information

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection

More information

9 Control Statements. 9.1 Introduction. 9.2 Objectives. 9.3 Statements

9 Control Statements. 9.1 Introduction. 9.2 Objectives. 9.3 Statements 9 Control Statements 9.1 Introduction The normal flow of execution in a high level language is sequential, i.e., each statement is executed in the order of its appearance in the program. However, depending

More information

Writing Control Structures

Writing Control Structures Writing Control Structures Copyright 2006, Oracle. All rights reserved. Oracle Database 10g: PL/SQL Fundamentals 5-1 Objectives After completing this lesson, you should be able to do the following: Identify

More information

How To Use Matlab

How To Use Matlab INTRODUCTION TO MATLAB FOR ENGINEERING STUDENTS David Houcque Northwestern University (version 1.2, August 2005) Contents 1 Tutorial lessons 1 1 1.1 Introduction.................................... 1 1.2

More information

Computational Mathematics with Python

Computational Mathematics with Python Computational Mathematics with Python Basics Claus Führer, Jan Erik Solem, Olivier Verdier Spring 2010 Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring 2010 1

More information

Introduction to Minitab Macros. Types of Minitab Macros. Objectives. Local Macros. Global Macros

Introduction to Minitab Macros. Types of Minitab Macros. Objectives. Local Macros. Global Macros Minitab Macros 10.1 Introduction to Minitab Macros 10.2 Global Minitab Macros 10.3 Local Minitab Macros 10.4 Advanced Minitab Macro Programming 10.5 Hints on Debugging Macros Introduction to Minitab Macros

More information

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share.

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share. LING115 Lecture Note Session #4 Python (1) 1. Introduction As we have seen in previous sessions, we can use Linux shell commands to do simple text processing. We now know, for example, how to count words.

More information

In this Chapter you ll learn:

In this Chapter you ll learn: Now go, write it before them in a table, and note it in a book. Isaiah 30:8 To go beyond is as wrong as to fall short. Confucius Begin at the beginning, and go on till you come to the end: then stop. Lewis

More information

Hands-on Exercise 1: VBA Coding Basics

Hands-on Exercise 1: VBA Coding Basics Hands-on Exercise 1: VBA Coding Basics This exercise introduces the basics of coding in Access VBA. The concepts you will practise in this exercise are essential for successfully completing subsequent

More information

1 Description of The Simpletron

1 Description of The Simpletron Simulating The Simpletron Computer 50 points 1 Description of The Simpletron In this assignment you will write a program to simulate a fictional computer that we will call the Simpletron. As its name implies

More information

Exercise 1: Python Language Basics

Exercise 1: Python Language Basics Exercise 1: Python Language Basics In this exercise we will cover the basic principles of the Python language. All languages have a standard set of functionality including the ability to comment code,

More information

Final Exam Review: VBA

Final Exam Review: VBA Engineering Fundamentals ENG1100 - Session 14B Final Exam Review: VBA 1 //coe/dfs/home/engclasses/eng1101/f03/ethics/en1.e05.finalcoursewrapup.sxi Final Programming Exam Topics Flowcharts Assigning Variables

More information

PL / SQL Basics. Chapter 3

PL / SQL Basics. Chapter 3 PL / SQL Basics Chapter 3 PL / SQL Basics PL / SQL block Lexical units Variable declarations PL / SQL types Expressions and operators PL / SQL control structures PL / SQL style guide 2 PL / SQL Block Basic

More information

Version 1.5 Satlantic Inc.

Version 1.5 Satlantic Inc. SatCon Data Conversion Program Users Guide Version 1.5 Version: 1.5 (B) - March 09, 2011 i/i TABLE OF CONTENTS 1.0 Introduction... 1 2.0 Installation... 1 3.0 Glossary of terms... 1 4.0 Getting Started...

More information

Introductory Course to Matlab with Financial Case Studies

Introductory Course to Matlab with Financial Case Studies University of Cyprus Public Business Administration Department Introductory Course to Matlab with Financial Case Studies Prepared by: Panayiotis Andreou PhD Candidate PBA UCY Lefkosia, September 003 Table

More information

JavaScript: Control Statements I

JavaScript: Control Statements I 1 7 JavaScript: Control Statements I 7.1 Introduction 2 The techniques you will learn here are applicable to most high-level languages, including JavaScript 1 7.2 Algorithms 3 Any computable problem can

More information

6. Control Structures

6. Control Structures - 35 - Control Structures: 6. Control Structures A program is usually not limited to a linear sequence of instructions. During its process it may bifurcate, repeat code or take decisions. For that purpose,

More information

PL/SQL Overview. Basic Structure and Syntax of PL/SQL

PL/SQL Overview. Basic Structure and Syntax of PL/SQL PL/SQL Overview PL/SQL is Procedural Language extension to SQL. It is loosely based on Ada (a variant of Pascal developed for the US Dept of Defense). PL/SQL was first released in ١٩٩٢ as an optional extension

More information

(!' ) "' # "*# "!(!' +,

(!' ) ' # *# !(!' +, Normally, when single line commands are entered, MATLAB processes the commands immediately and displays the results. MATLAB is also capable of processing a sequence of commands that are stored in files

More information

3. Add and delete a cover page...7 Add a cover page... 7 Delete a cover page... 7

3. Add and delete a cover page...7 Add a cover page... 7 Delete a cover page... 7 Microsoft Word: Advanced Features for Publication, Collaboration, and Instruction For your MAC (Word 2011) Presented by: Karen Gray (kagray@vt.edu) Word Help: http://mac2.microsoft.com/help/office/14/en-

More information

Introduction to Matrix Algebra

Introduction to Matrix Algebra Psychology 7291: Multivariate Statistics (Carey) 8/27/98 Matrix Algebra - 1 Introduction to Matrix Algebra Definitions: A matrix is a collection of numbers ordered by rows and columns. It is customary

More information

Windows PowerShell Essentials

Windows PowerShell Essentials Windows PowerShell Essentials Windows PowerShell Essentials Edition 1.0. This ebook is provided for personal use only. Unauthorized use, reproduction and/or distribution strictly prohibited. All rights

More information

Basic Concepts in Matlab

Basic Concepts in Matlab Basic Concepts in Matlab Michael G. Kay Fitts Dept. of Industrial and Systems Engineering North Carolina State University Raleigh, NC 769-7906, USA kay@ncsu.edu September 00 Contents. The Matlab Environment.

More information

PYTHON Basics http://hetland.org/writing/instant-hacking.html

PYTHON Basics http://hetland.org/writing/instant-hacking.html CWCS Workshop May 2009 PYTHON Basics http://hetland.org/writing/instant-hacking.html Python is an easy to learn, modern, interpreted, object-oriented programming language. It was designed to be as simple

More information

InTouch HMI Scripting and Logic Guide

InTouch HMI Scripting and Logic Guide InTouch HMI Scripting and Logic Guide Invensys Systems, Inc. Revision A Last Revision: 7/25/07 Copyright 2007 Invensys Systems, Inc. All Rights Reserved. All rights reserved. No part of this documentation

More information

Retrieving Data Using the SQL SELECT Statement. Copyright 2006, Oracle. All rights reserved.

Retrieving Data Using the SQL SELECT Statement. Copyright 2006, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement Objectives After completing this lesson, you should be able to do the following: List the capabilities of SQL SELECT statements Execute a basic SELECT statement

More information

MICROSOFT EXCEL FORMULAS

MICROSOFT EXCEL FORMULAS MICROSOFT EXCEL FORMULAS Building Formulas... 1 Writing a Formula... 1 Parentheses in Formulas... 2 Operator Precedence... 2 Changing the Operator Precedence... 2 Functions... 3 The Insert Function Button...

More information

There are six different windows that can be opened when using SPSS. The following will give a description of each of them.

There are six different windows that can be opened when using SPSS. The following will give a description of each of them. SPSS Basics Tutorial 1: SPSS Windows There are six different windows that can be opened when using SPSS. The following will give a description of each of them. The Data Editor The Data Editor is a spreadsheet

More information

Macros in Word & Excel

Macros in Word & Excel Macros in Word & Excel Description: If you perform a task repeatedly in Word or Excel, you can automate the task by using a macro. A macro is a series of steps that is grouped together as a single step

More information

MATLAB Primer. R2015a

MATLAB Primer. R2015a MATLAB Primer R25a How to Contact MathWorks Latest news: www.mathworks.com Sales and services: www.mathworks.com/sales_and_services User community: www.mathworks.com/matlabcentral Technical support: www.mathworks.com/support/contact_us

More information

EXCEL SOLVER TUTORIAL

EXCEL SOLVER TUTORIAL ENGR62/MS&E111 Autumn 2003 2004 Prof. Ben Van Roy October 1, 2003 EXCEL SOLVER TUTORIAL This tutorial will introduce you to some essential features of Excel and its plug-in, Solver, that we will be using

More information

Operation Count; Numerical Linear Algebra

Operation Count; Numerical Linear Algebra 10 Operation Count; Numerical Linear Algebra 10.1 Introduction Many computations are limited simply by the sheer number of required additions, multiplications, or function evaluations. If floating-point

More information

Q&As: Microsoft Excel 2013: Chapter 2

Q&As: Microsoft Excel 2013: Chapter 2 Q&As: Microsoft Excel 2013: Chapter 2 In Step 5, why did the date that was entered change from 4/5/10 to 4/5/2010? When Excel recognizes that you entered a date in mm/dd/yy format, it automatically formats

More information

MATLAB Tutorial. Chapter 6. Writing and calling functions

MATLAB Tutorial. Chapter 6. Writing and calling functions MATLAB Tutorial Chapter 6. Writing and calling functions In this chapter we discuss how to structure a program with multiple source code files. First, an explanation of how code files work in MATLAB is

More information

Chapter 5 Programming Statements. Chapter Table of Contents

Chapter 5 Programming Statements. Chapter Table of Contents Chapter 5 Programming Statements Chapter Table of Contents OVERVIEW... 57 IF-THEN/ELSE STATEMENTS... 57 DO GROUPS... 58 IterativeExecution... 59 JUMPING... 61 MODULES... 62 Defining and Executing a Module....

More information

MS Access: Advanced Tables and Queries. Lesson Notes Author: Pamela Schmidt

MS Access: Advanced Tables and Queries. Lesson Notes Author: Pamela Schmidt Lesson Notes Author: Pamela Schmidt Tables Text Fields (Default) Text or combinations of text and numbers, as well as numbers that don't require calculations, such as phone numbers. or the length set by

More information

FIRST STEPS WITH SCILAB

FIRST STEPS WITH SCILAB powered by FIRST STEPS WITH SCILAB The purpose of this tutorial is to get started using Scilab, by discovering the environment, the main features and some useful commands. Level This work is licensed under

More information

Lecture 4. Input and output. Scilab/Matlab automatically displays the value of a variable when you type its name at the command line.

Lecture 4. Input and output. Scilab/Matlab automatically displays the value of a variable when you type its name at the command line. 1 Introduction Lecture 4 Input and output The deliverable of a computer program is its output. Output may be in graphical form as in a two-dimensional function plot, or it may be in text form as in a table

More information

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0 VISUAL GUIDE to RX Scripting for Roulette Xtreme - System Designer 2.0 UX Software - 2009 TABLE OF CONTENTS INTRODUCTION... ii What is this book about?... iii How to use this book... iii Time to start...

More information

Simple Programming in MATLAB. Plotting a graph using MATLAB involves three steps:

Simple Programming in MATLAB. Plotting a graph using MATLAB involves three steps: Simple Programming in MATLAB Plotting Graphs: We will plot the graph of the function y = f(x) = e 1.5x sin(8πx), 0 x 1 Plotting a graph using MATLAB involves three steps: Create points 0 = x 1 < x 2

More information

What is a Loop? Pretest Loops in C++ Types of Loop Testing. Count-controlled loops. Loops can be...

What is a Loop? Pretest Loops in C++ Types of Loop Testing. Count-controlled loops. Loops can be... What is a Loop? CSC Intermediate Programming Looping A loop is a repetition control structure It causes a single statement or a group of statements to be executed repeatedly It uses a condition to control

More information

Using Casio Graphics Calculators

Using Casio Graphics Calculators Using Casio Graphics Calculators (Some of this document is based on papers prepared by Donald Stover in January 2004.) This document summarizes calculation and programming operations with many contemporary

More information

grep, awk and sed three VERY useful command-line utilities Matt Probert, Uni of York grep = global regular expression print

grep, awk and sed three VERY useful command-line utilities Matt Probert, Uni of York grep = global regular expression print grep, awk and sed three VERY useful command-line utilities Matt Probert, Uni of York grep = global regular expression print In the simplest terms, grep (global regular expression print) will search input

More information

MATLAB DFS. Interface Library. User Guide

MATLAB DFS. Interface Library. User Guide MATLAB DFS Interface Library User Guide DHI Water Environment Health Agern Allé 5 DK-2970 Hørsholm Denmark Tel: +45 4516 9200 Fax: +45 4516 9292 E-mail: dhi@dhigroup.com Web: www.dhigroup.com 2007-03-07/MATLABDFS_INTERFACELIBRARY_USERGUIDE.DOC/JGR/HKH/2007Manuals/lsm

More information

Lecture 2 Mathcad Basics

Lecture 2 Mathcad Basics Operators Lecture 2 Mathcad Basics + Addition, - Subtraction, * Multiplication, / Division, ^ Power ( ) Specify evaluation order Order of Operations ( ) ^ highest level, first priority * / next priority

More information

Import Filter Editor User s Guide

Import Filter Editor User s Guide Reference Manager Windows Version Import Filter Editor User s Guide April 7, 1999 Research Information Systems COPYRIGHT NOTICE This software product and accompanying documentation is copyrighted and all

More information