3+2 3*2 3/2 3^2 3**2 In matlab, use ^ or ** for exponentiation. In fortran, use only ** not ^ VARIABLES LECTURE 1: ARITHMETIC AND FUNCTIONS

Size: px
Start display at page:

Download "3+2 3*2 3/2 3^2 3**2 In matlab, use ^ or ** for exponentiation. In fortran, use only ** not ^ VARIABLES LECTURE 1: ARITHMETIC AND FUNCTIONS"

Transcription

1 LECTURE 1: ARITHMETIC AND FUNCTIONS MATH 190 WEBSITE: gautier/190.html PREREQUISITE: You must have taken or be taking Calculus I concurrently. If not taken here, specify the college and course title/number. Otherwise, drop this class now. If you don t need Matlab or Fortran, maybe you shouldnt be in this class.choose your seat carefully, it will be your seat for rest of the term. Print and sign your name on the sign-up sheet. Record: login name, password. MATLAB (SCILAB) AND FORTRAN Fortran (in engineering) is used when maximum speed is needed in math/engineering applications. Matlab (in engineering) was originally used for numerical computations. It now has a lot of capabilities and can be used for symbolic math as well (handling formulas instead of numbers). This course teaches the basic notions of programming, using Matlab (easier to use but slower) and Fortran (the fastest programming language but harder to use). These languages have the biggest engineering program libraries, even though langages such as Python or C are very wide-spread and are also fundamental for engineers. We ll have six lectures about Matlab and then 5 lectures about Fortran. On your home computer (1) install a free version of Matlab (Scilab) and (2) a compiler (g95.exe or gfortran or FTN95 Fortran) and editor (SciTE) for Fortran. Go to the class website for instructions on both Scilab and Fortran. Try to have Scilab, Fortran and SciTE up and running by the next class. If you cant get either g95 or gfortran or FTN95 installed, you can use the online compiler compileonline ( Warning: installing Fortran may be hard *2 3/2 3^2 3**2 In matlab, use ^ or ** for exponentiation. In fortran, use only ** not ^ VARIABLES a variables must be initialized a = 2 a=2 spaces dont matter a A Matlab is case sensitive, Fortran is not. b=3 a+b ab a*b must use * for products, ab is two-letter variable name it is not a*b cost=8*3*5 cost is a variable just like x, y, z () s PRECEDENCE When calculating an algebraic expression, ˆ has the priority, then * and /, then + and -. Hence a*b^2-4*d = (a*(b^2))-(4*d) a*b/c*d =? add ( )s to remove unambiguity (a*b)/(c*d) a*(b/c)*d a+b-c+d =? rewrite with added ( )s (a+b)-(c+d) a+(b-c)+d) -2^2 (-2)^2 ARITHMETIC Double-click the Scilab icon (top center, black with red dots). Enter the following: 1

2 EUCLIDIAN DIVISION modulo(13,5) the remainder of 13/5, mod(13,5) in fortran floor(13/5) no builtin quotient function but this command gives the same result Can you guess what is the role played by the function floor? ASSIGNMENTS AND EQUALITY TESTS. In math, x = 2 means x equals 2. In MatLab, x = 2 is the assignment command which sets x equal to 2 (any earlier value is lost). In other words, the variable x contains the value 2. To test if x equals 2 in Matlab, that is to say to check if the variable x contains the value 2, write x == 2. x no value is assigned to the variable x x=2 the value 2 is assigned to the variable x x==2 T=True, it is true that the variable x equals 2 x==0 F=False, it is false that the variable x equals 0 x==x+1 is always false. x=input( Enter a number. > ) gets x from keyboard the value of x is entered by the user x<=3 test if x 3 x>=3 test if x 3 x =3 test if x 3 We can now use the built-in commands that we have learned so far to write our first function. A function is a little program which executes a sequence of instructions.. A function may need an argument, which is a specific input provided by the user. The codes of the functions are written in SciNotes, not in Scilab. To execute a function, follow the process: 1. Click Applications/SciNotes to open SciNotes. 2. Write the function, along with lines which test it. 3. Save it, using the extension.sci 4. Select Execute... file with echo or <ctrl-l>. (Note the answers in the Scilab window). Save as even odd. 5. Once a function has been executed, it may be used in Scilab. x=x+1 x+1=x we update the value of the variable x the new value of x (on left) is the old value of x plus 1 (on right new value of x is 2+1 so 3 doesn t work need variable on the left, formula on right c1.0 (Together). Write a function even odd(n) which returns even if n is even, odd if not. Test it on 0 (enter even odd(0) in Scilab) and 1 (enter even odd(1) in Scilab). IMPORTANT: here, the variable n is the argument of the function even odd. It can be any integer. To test the function, we replace n by 0 and 1, and the function tells us if 0 and 1 are even or odd numbers. 2

3 PRINTING SUPPRESSION x=0 x=1; x To suppress printing to the monitor, end lines with ;. MULTIPLE COMMANDS PER LINE To enter several commands on the same line, separate them with ; (no printing) or, (printing). x=1, x=x+1, x=x**2 x=1; x=x+1; x=x**2 What is printed? CONSTANTS AND BUILT-IN FUNCTIONS x=100 %pi = π = %e = log(x) natural logarithm log10(x) common base-10 logarithm sqrt(4) 4 abs(-3) absolute value -3 round(4.5) rounds to nearest integer ceil(4.5) rounds up to nearest >= integer floor(4.5) rounds down to nearest <= integer factorial(3) = 3! = 3*2*1 sin(%pi/2) angles are in radians, not degrees rand() returns a random number between 0 and 1 The trig functions sin, cos, tan are in radians. Their inverses are the builtin functions atan, asin, acos. COMMENTS In Scilab // indicates a comment which Scilab ignores. In Matlab % precedes comments; in Fortran it is!. One of the next two lines gives an error. log(2.72) natural logarithm log(2.72) //natural logarithm ERRORS, HELP Scilab has no mouse cursor (when a cursor is needed, use the SciNotes editor window). Fix typos, with the backspace (destructive) or back arrow key (nondestructive). Copy/paste the next line then press <enter> sin[%pi*x/12) Retrieve this line using the up arrow.use the back arrow key to correct. You must change the [ into a (. To get help enter: help To get help about matrices, enter: help matrix SAVING a=[1,2,3; 4,5,6] When you close Scilab, all values are lost. Heres how to save a and all other entered data to some file, say x1.sav: Select file/save environment from the top left menu. Select Desktop in the Save in: box. Enter prob1.sav in the File name: box. a clear //clears all variables clear a,x clears just a and x To load the saved data select file/load environment (not file/open...) and select the filename. 3

4 MATLAB VARIABLES ARE INDEPENDENT x=2 f=2*x x=3 f //changing x doesnt change f, it is a memory location. Matlab variables are independent (they dont depend on other variables). To make f a dependent variable whose value changes as x changes, define it as a function f(x). For every function you define, always add at least one line after the function which tests it. To quit Scilab, enter quit WRITING CLASSWORK/HOMEWORK PROBLEMS. Classwork are the problems solved together during the class time. WRITE FUNCTIONS IN SCINOTES Do all classwork and homework in SciNotes, never in the SciLab.. The mouse cursor doesnt work in SciLab but does work in SciNotes. To turn auto completion off, select: Preferences>Auto-completion. Exemple: Write a function volsphere(r) which gives the volume 4πr3 3 of a sphere of radius r. In SciNotes, Select File/New (or <ctrl-n>). Copy/paste the next 4 lines to SciNotes (SciNotes, not SciLab). function V=volsphere(r) V=4*%pi*r**3/3; endfunction volsphere(6) Select Execute... file with echo or <ctrl-l> The answer should be Once the function has been executed, it may be used in Scilab. In the Scilab window, enter volsphere(10) This gives the volume of a sphere of radius 10. To save the function: click File/Save, enter a file name, click save. Entering volsphere, this makes a file volsphere.sce. To open this file in a later session, box click File/Open,, select the file name. To execute the function, select Execute...file with echo to put it in Scilab. DO NOT TURN IN THE CLASSWORK. For each classwork, follow the instructions : 1. Select File/New (or <ctrl-n>), 2. Paste the problems template comment into the file. 3. Select File/Save (or <ctrl-s>) and enter the file name. Make sure the directory is H: 4. Add the needed Scilab code and test lines. 5. Test using Execute/... with echo (or <ctrl-l >). 6. Save using File/Save (or <ctrl-s>). Unsaved work gets lost! c1.1. Write a function which calculates the length x 2 + y 2 + z 2 of the vector [x, y, z]. //c1.1 Function for the length of [x,y,z]. Add a line which tests it. c1.2. Write a function which calculates the surface area of a w l h box with a bottom, four sides but no top. Include a testing line. //c1.2 Function for the surface area of a w,l,h box with no top. Add a test line. 4

5 c1.3. Write a function which tosses a coin giving H or T for heads or tails. Test it by tossing the coin 20 times. //c1.3 A function which tosses a coin. //Toss it 10 times. Should get random Hs, Ts. c1.4 In SciNotes, write a Scilab formula which calculates π 5. Write just the 11 symbols of the formula (no function). //c1.4(1) Formula for the square root of pi to the 5th. Answer: c1.5. Write a Scilab function f(x) which calculates 1 + x + x2 + x3 for 2 3 any x. Add a line which tests f(x) on x = 12. Select File/New in SciNotes, copy/paste the commented template lines to SciNotes. Save. Fill in the required Scilab code. Execute...with echo. //c1.5(2) Function f(x) = 1+x+...+x**3/3. //Test f(x) on x=12. Answer: 661. Send all the problems in one to gautier@math.hawaii.edu with the subject line 190 h1(8). To do so, Copy/paste all homework problems into the message body. To copy lines from SciNotes to an message, highlight the lines to be copied and press <ctrl-c> or select edit/copy. Then put the cursor where you wish to paste the lines, and press <ctrl-v> or select edit/paste. Don t attach files Avoid formatting. Paste into with plain text set or right-click to get paste without formatting. Formatted text causes errors when run in SciLab, which may make you lose points. Do not send Scilab answers, send only SciNote lines. Do not add anything else to the , not even a problem number or your name. If you must add a comment, put // before the comment so it wont give errors in Scilab. c1.6. Define (in SciNotes) a function vol can(r,h) which calculates the volume V = πr 2 h of a cylinder of radius r and height h. Add a fourth line which uses the function to find the volume of a can of radius 10 and height 4. File/New in SciNotes, copy/paste the template lines to SciNotes. Fill in the required Scilab code.. //c1.6(2) A function vol can(r,h) for the volume V of a can of radius r,height h. //Use it on a can of radius 10, height 4. Answer: Homework are the problems that you have to solve by yourselves at home. A list of homework will be assigned every week. It will be due before the first class of the following week HOMEWORK 1 IS DUE BEFORE FRIDAY JANUARY 23RD. 5 Test your . Select the entire message <ctrl-a>, copy it <ctrl-c>, paste it <ctrl-v> into Scilab. Press <enter>. All problems should run, one after the other with no errors. Ignore redefining function warnings. Copy the subject line exactly. Send your h1.1(1). Rewrite this sequence so that the b doesnt print. Make only one change. Keep it on one line. a=1,b=a+1,a=2,c=2*b**a/2+3 h1.2(1) Rewrite this sequence so that the a s dont print. Make only two changes. Keep it on one line. a=1,b=a+1,a=2,c=2*b**a/2+3 //h1.2(1) Rewrite so the a s dont print.

6 h1.3(3). Write a Scilab function (in SciNotes!) which calculates the volume of a box of height h, width w, length l. Include a following line which uses it to calculate the volume of box (should be 4 lines, all entered in SciNotes). //h1.3(3) Scilab function for the volume //of a box of dimensions wxlxh. Add a //line after the function which uses it //to find the vol. of a 1x2x3 box. Ans: 6 h1.4(3). Write a Scilab function g(x) whose value is log 10 (x). Add a line that uses this function to compute log 10 (30). //h1.4(3) 3 function lines, 1 testing line. //Answer: 1.21 SCILAB DISPLAY (OPTIONAL) When you execute a function, Scilab displays a warning that the function is being redefined. To disable this enter funcprot(0) in the Scilab window. To get rid of the ans = message, use the disp(... ) function. To turn auto completion off, select Preferences and uncheck Auto-completion. Pressing <F2> clears Scilabs console window. 6

Lecture 1 arithmetic and functions

Lecture 1 arithmetic and functions Lecture 1 arithmetic and functions MATH 190 WEBSITE: www.math.hawaii.edu/190 Open MATH 190 in a web browser. Read and accept the Terms of Acceptable Lab Use. Open Lecture 1. PREREQUISITE: You must have

More information

Math 2250 MATLAB TUTORIAL Fall 2005

Math 2250 MATLAB TUTORIAL Fall 2005 Math 2250 MATLAB TUTORIAL Fall 2005 Math Computer Lab The Mathematics Computer Lab is located in the T. Benny Rushing Mathematics Center (located underneath the plaza connecting JWB and LCB) room 155C.

More information

190 Lecture 11 Fortran arithmetic

190 Lecture 11 Fortran arithmetic 190 Lecture 11 Fortran arithmetic Open Lecture 1. Open SciTE (black death star) not Scilab We cover these chapters of your Fortran text: 7&8, 9&10, 11&12, 13&14, 15&16, 17&18, 19&22, 23. Reading assignment:

More information

1 0 3 y 2. In SciNotes, enter the augmented matrix, then rref(a).

1 0 3 y 2. In SciNotes, enter the augmented matrix, then rref(a). 190 Lecture 5 equations graphs integrals Open MATH 190 in a browser; select Lecture 5 Double-click the SciLab icon. See Chapter 3, 10 of text for details. SOLVING SIMULTANEOUS EQUATIONS. EXAMPLE e4.1 Solve

More information

190 Lecture 11 Fortran arithmetic

190 Lecture 11 Fortran arithmetic 190 Lecture 11 Fortran arithmetic Open Lecture 1. Open SciTE (black death star) not Scilab We cover these chapters of your Fortran text: 7&8, 9&10, 11&12, 13&14, 15&16, 17&18, 19&22, 23. Reading assignment:

More information

SOLVING SIMULTANEOUS EQUATIONS. EXAMPLE e4.1 Solve Corresponding augmented matrix 2x 4y 2 a 242 x 3y 3

SOLVING SIMULTANEOUS EQUATIONS. EXAMPLE e4.1 Solve Corresponding augmented matrix 2x 4y 2 a 242 x 3y 3 190 Lecture 5 equations graphs integrals Open MATH 190 in a browser; select Lecture 5 Double-click the SciLab icon. See Chapter 3, 10 of text for details. SOLVING SIMULTANEOUS EQUATIONS. EXAMPLE e4.1 Solve

More information

190 Lecture 11 Fortran arithmetic

190 Lecture 11 Fortran arithmetic 190 Lecture 11 Fortran arithmetic Open Lecture 1. Open SciTE (black death star) not Scilab We cover these chapters of your Fortran text: 7&8, 9&10, 11&12, 13&14, 15&16, 17&18, 19&22, 23. Reading assignment:

More information

Dr Richard Greenaway

Dr Richard Greenaway SCHOOL OF PHYSICS, ASTRONOMY & MATHEMATICS 4PAM1008 MATLAB 2 Basic MATLAB Operation Dr Richard Greenaway 2 Basic MATLAB Operation 2.1 Overview 2.1.1 The Command Line In this Workshop you will learn how

More information

Introduction to Engineering gii

Introduction to Engineering gii 25.108 Introduction to Engineering gii Dr. Jay Weitzen Lecture Notes I: Introduction to Matlab from Gilat Book MATLAB - Lecture # 1 Starting with MATLAB / Chapter 1 Topics Covered: 1. Introduction. 2.

More information

SECTION 1: INTRODUCTION. ENGR 112 Introduction to Engineering Computing

SECTION 1: INTRODUCTION. ENGR 112 Introduction to Engineering Computing SECTION 1: INTRODUCTION ENGR 112 Introduction to Engineering Computing 2 Course Overview What is Programming? 3 Programming The implementation of algorithms in a particular computer programming language

More information

The Very Basics of the R Interpreter

The Very Basics of the R Interpreter Chapter 2 The Very Basics of the R Interpreter OK, the computer is fired up. We have R installed. It is time to get started. 1. Start R by double-clicking on the R desktop icon. 2. Alternatively, open

More information

Our Strategy for Learning Fortran 90

Our Strategy for Learning Fortran 90 Our Strategy for Learning Fortran 90 We want to consider some computational problems which build in complexity. evaluating an integral solving nonlinear equations vector/matrix operations fitting data

More information

LAB 1 General MATLAB Information 1

LAB 1 General MATLAB Information 1 LAB 1 General MATLAB Information 1 General: To enter a matrix: > type the entries between square brackets, [...] > enter it by rows with elements separated by a space or comma > rows are terminated by

More information

Basic stuff -- assignments, arithmetic and functions

Basic stuff -- assignments, arithmetic and functions Basic stuff -- assignments, arithmetic and functions Most of the time, you will be using Maple as a kind of super-calculator. It is possible to write programs in Maple -- we will do this very occasionally,

More information

Lab 1 Intro to MATLAB and FreeMat

Lab 1 Intro to MATLAB and FreeMat Lab 1 Intro to MATLAB and FreeMat Objectives concepts 1. Variables, vectors, and arrays 2. Plotting data 3. Script files skills 1. Use MATLAB to solve homework problems 2. Plot lab data and mathematical

More information

Outline. CSE 1570 Interacting with MATLAB. Outline. Starting MATLAB. MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An.

Outline. CSE 1570 Interacting with MATLAB. Outline. Starting MATLAB. MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An. CSE 10 Interacting with MATLAB Instructor: Aijun An Department of Computer Science and Engineering York University aan@cse.yorku.ca Outline Starting MATLAB MATLAB Windows Using the Command Window Some

More information

Computational Physics

Computational Physics Computational Physics Python Programming Basics Prof. Paul Eugenio Department of Physics Florida State University Jan 17, 2019 http://hadron.physics.fsu.edu/~eugenio/comphy/ Announcements Exercise 0 due

More information

Outline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline (Cont d) MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An

Outline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline (Cont d) MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An CSE 170 Interacting with MATLAB Instructor: Aijun An Department of Computer Science and Engineering York University aan@cse.yorku.ca Outline Starting MATLAB MATLAB Windows Using the Command Window Some

More information

Outline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline. MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An.

Outline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline. MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An. CSE 170 Interacting with MATLAB Instructor: Aijun An Department of Computer Science and Engineering York University aan@cse.yorku.ca Outline Starting MATLAB MATLAB Windows Using the Command Window Some

More information

AMS 27L LAB #1 Winter 2009

AMS 27L LAB #1 Winter 2009 AMS 27L LAB #1 Winter 2009 Introduction to MATLAB Objectives: 1. To introduce the use of the MATLAB software package 2. To learn elementary mathematics in MATLAB Getting Started: Log onto your machine

More information

Python Programming Exercises 1

Python Programming Exercises 1 Python Programming Exercises 1 Notes: throughout these exercises >>> preceeds code that should be typed directly into the Python interpreter. To get the most out of these exercises, don t just follow them

More information

Variable Definition and Statement Suppression You can create your own variables, and assign them values using = >> a = a = 3.

Variable Definition and Statement Suppression You can create your own variables, and assign them values using = >> a = a = 3. MATLAB Introduction Accessing Matlab... Matlab Interface... The Basics... 2 Variable Definition and Statement Suppression... 2 Keyboard Shortcuts... More Common Functions... 4 Vectors and Matrices... 4

More information

PROGRAMMING WITH MATLAB DR. AHMET AKBULUT

PROGRAMMING WITH MATLAB DR. AHMET AKBULUT PROGRAMMING WITH MATLAB DR. AHMET AKBULUT OVERVIEW WEEK 1 What is MATLAB? A powerful software tool: Scientific and engineering computations Signal processing Data analysis and visualization Physical system

More information

MATLAB Programming for Numerical Computation Dr. Niket Kaisare Department Of Chemical Engineering Indian Institute of Technology, Madras

MATLAB Programming for Numerical Computation Dr. Niket Kaisare Department Of Chemical Engineering Indian Institute of Technology, Madras MATLAB Programming for Numerical Computation Dr. Niket Kaisare Department Of Chemical Engineering Indian Institute of Technology, Madras Module No. #01 Lecture No. #1.1 Introduction to MATLAB programming

More information

MATLAB Project: Getting Started with MATLAB

MATLAB Project: Getting Started with MATLAB Name Purpose: To learn to create matrices and use various MATLAB commands for reference later MATLAB built-in functions used: [ ] : ; + - * ^, size, help, format, eye, zeros, ones, diag, rand, round, cos,

More information

General MATLAB Information 1

General MATLAB Information 1 Introduction to MATLAB General MATLAB Information 1 Once you initiate the MATLAB software, you will see the MATLAB logo appear and then the MATLAB prompt >>. The prompt >> indicates that MATLAB is awaiting

More information

Introduction to Programming with RAPTOR

Introduction to Programming with RAPTOR Introduction to Programming with RAPTOR By Dr. Wayne Brown What is RAPTOR? RAPTOR is a visual programming development environment based on flowcharts. A flowchart is a collection of connected graphic symbols,

More information

Matlab as a calculator

Matlab as a calculator Why Matlab? Matlab is an interactive, high-level, user-friendly programming and visualization environment. It allows much faster programs development in comparison with the traditional low-level compiled

More information

ELEMENTARY MATLAB PROGRAMMING

ELEMENTARY MATLAB PROGRAMMING 1 ELEMENTARY MATLAB PROGRAMMING (Version R2013a used here so some differences may be encountered) COPYRIGHT Irving K. Robbins 1992, 1998, 2014, 2015 All rights reserved INTRODUCTION % It is assumed the

More information

Introduction to MATLAB

Introduction to MATLAB Outlines September 9, 2004 Outlines Part I: Review of Previous Lecture Part II: Part III: Writing MATLAB Functions Review of Previous Lecture Outlines Part I: Review of Previous Lecture Part II: Part III:

More information

Chapter 1 Introduction to MATLAB

Chapter 1 Introduction to MATLAB Chapter 1 Introduction to MATLAB 1.1 What is MATLAB? MATLAB = MATrix LABoratory, the language of technical computing, modeling and simulation, data analysis and processing, visualization and graphics,

More information

Finding, Starting and Using Matlab

Finding, Starting and Using Matlab Variables and Arrays Finding, Starting and Using Matlab CSC March 6 &, 9 Array: A collection of data values organized into rows and columns, and known by a single name. arr(,) Row Row Row Row 4 Col Col

More information

Starting MATLAB To logon onto a Temple workstation at the Tech Center, follow the directions below.

Starting MATLAB To logon onto a Temple workstation at the Tech Center, follow the directions below. What is MATLAB? MATLAB (short for MATrix LABoratory) is a language for technical computing, developed by The Mathworks, Inc. (A matrix is a rectangular array or table of usually numerical values.) MATLAB

More information

Excel R Tips. is used for multiplication. + is used for addition. is used for subtraction. / is used for division

Excel R Tips. is used for multiplication. + is used for addition. is used for subtraction. / is used for division Excel R Tips EXCEL TIP 1: INPUTTING FORMULAS To input a formula in Excel, click on the cell you want to place your formula in, and begin your formula with an equals sign (=). There are several functions

More information

MATLAB Project: Getting Started with MATLAB

MATLAB Project: Getting Started with MATLAB Name Purpose: To learn to create matrices and use various MATLAB commands for reference later MATLAB functions used: [ ] : ; + - * ^, size, help, format, eye, zeros, ones, diag, rand, round, cos, sin,

More information

MATLAB Constants, Variables & Expression. 9/12/2015 By: Nafees Ahmed

MATLAB Constants, Variables & Expression. 9/12/2015 By: Nafees Ahmed MATLAB Constants, Variables & Expression Introduction MATLAB can be used as a powerful programming language. It do have IF, WHILE, FOR lops similar to other programming languages. It has its own vocabulary

More information

Constraint-based Metabolic Reconstructions & Analysis H. Scott Hinton. Matlab Tutorial. Lesson: Matlab Tutorial

Constraint-based Metabolic Reconstructions & Analysis H. Scott Hinton. Matlab Tutorial. Lesson: Matlab Tutorial 1 Matlab Tutorial 2 Lecture Learning Objectives Each student should be able to: Describe the Matlab desktop Explain the basic use of Matlab variables Explain the basic use of Matlab scripts Explain the

More information

Introduction to MATLAB Programming

Introduction to MATLAB Programming Introduction to MATLAB Programming Arun A. Balakrishnan Asst. Professor Dept. of AE&I, RSET Overview 1 Overview 2 Introduction 3 Getting Started 4 Basics of Programming Overview 1 Overview 2 Introduction

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB The Desktop When you start MATLAB, the desktop appears, containing tools (graphical user interfaces) for managing files, variables, and applications associated with MATLAB. The following

More information

Numerical Methods Lecture 1

Numerical Methods Lecture 1 Numerical Methods Lecture 1 Basics of MATLAB by Pavel Ludvík The recommended textbook: Numerical Methods Lecture 1 by Pavel Ludvík 2 / 30 The recommended textbook: Title: Numerical methods with worked

More information

Computer Project: Getting Started with MATLAB

Computer Project: Getting Started with MATLAB Computer Project: Getting Started with MATLAB Name Purpose: To learn to create matrices and use various MATLAB commands. Examples here can be useful for reference later. MATLAB functions: [ ] : ; + - *

More information

Programming in Mathematics. Mili I. Shah

Programming in Mathematics. Mili I. Shah Programming in Mathematics Mili I. Shah Starting Matlab Go to http://www.loyola.edu/moresoftware/ and login with your Loyola name and password... Matlab has eight main windows: Command Window Figure Window

More information

Starting Matlab. MATLAB Laboratory 09/09/10 Lecture. Command Window. Drives/Directories. Go to.

Starting Matlab. MATLAB Laboratory 09/09/10 Lecture. Command Window. Drives/Directories. Go to. Starting Matlab Go to MATLAB Laboratory 09/09/10 Lecture Lisa A. Oberbroeckling Loyola University Maryland loberbroeckling@loyola.edu http://ctx.loyola.edu and login with your Loyola name and password...

More information

Teaching Manual Math 2131

Teaching Manual Math 2131 Math 2131 Linear Algebra Labs with MATLAB Math 2131 Linear algebra with Matlab Teaching Manual Math 2131 Contents Week 1 3 1 MATLAB Course Introduction 5 1.1 The MATLAB user interface...........................

More information

Introduction to GNU-Octave

Introduction to GNU-Octave Introduction to GNU-Octave Dr. K.R. Chowdhary, Professor & Campus Director, JIETCOE JIET College of Engineering Email: kr.chowdhary@jietjodhpur.ac.in Web-Page: http://www.krchowdhary.com July 11, 2016

More information

Lecture 1: Hello, MATLAB!

Lecture 1: Hello, MATLAB! Lecture 1: Hello, MATLAB! Math 98, Spring 2018 Math 98, Spring 2018 Lecture 1: Hello, MATLAB! 1 / 21 Syllabus Instructor: Eric Hallman Class Website: https://math.berkeley.edu/~ehallman/98-fa18/ Login:!cmfmath98

More information

Lab#1: INTRODUCTION TO DERIVE

Lab#1: INTRODUCTION TO DERIVE Math 111-Calculus I- Fall 2004 - Dr. Yahdi Lab#1: INTRODUCTION TO DERIVE This is a tutorial to learn some commands of the Computer Algebra System DERIVE. Chapter 1 of the Online Calclab-book (see my webpage)

More information

Computer Programming in MATLAB

Computer Programming in MATLAB Computer Programming in MATLAB Prof. Dr. İrfan KAYMAZ Atatürk University Engineering Faculty Department of Mechanical Engineering What is a computer??? Computer is a device that computes, especially a

More information

Introduction to MATLAB

Introduction to MATLAB to MATLAB Spring 2019 to MATLAB Spring 2019 1 / 39 The Basics What is MATLAB? MATLAB Short for Matrix Laboratory matrix data structures are at the heart of programming in MATLAB We will consider arrays

More information

McTutorial: A MATLAB Tutorial

McTutorial: A MATLAB Tutorial McGill University School of Computer Science Sable Research Group McTutorial: A MATLAB Tutorial Lei Lopez Last updated: August 2014 w w w. s a b l e. m c g i l l. c a Contents 1 MATLAB BASICS 3 1.1 MATLAB

More information

Name: Dr. Fritz Wilhelm Lab 1, Presentation of lab reports Page # 1 of 7 5/17/2012 Physics 120 Section: ####

Name: Dr. Fritz Wilhelm Lab 1, Presentation of lab reports Page # 1 of 7 5/17/2012 Physics 120 Section: #### Name: Dr. Fritz Wilhelm Lab 1, Presentation of lab reports Page # 1 of 7 Lab partners: Lab#1 Presentation of lab reports The first thing we do is to create page headers. In Word 2007 do the following:

More information

A General Introduction to Matlab

A General Introduction to Matlab Master Degree Course in ELECTRONICS ENGINEERING http://www.dii.unimore.it/~lbiagiotti/systemscontroltheory.html A General Introduction to Matlab e-mail: luigi.biagiotti@unimore.it http://www.dii.unimore.it/~lbiagiotti

More information

A Guide to Using Some Basic MATLAB Functions

A Guide to Using Some Basic MATLAB Functions A Guide to Using Some Basic MATLAB Functions UNC Charlotte Robert W. Cox This document provides a brief overview of some of the essential MATLAB functionality. More thorough descriptions are available

More information

Variables are used to store data (numbers, letters, etc) in MATLAB. There are a few rules that must be followed when creating variables in MATLAB:

Variables are used to store data (numbers, letters, etc) in MATLAB. There are a few rules that must be followed when creating variables in MATLAB: Contents VARIABLES... 1 Storing Numerical Data... 2 Limits on Numerical Data... 6 Storing Character Strings... 8 Logical Variables... 9 MATLAB S BUILT-IN VARIABLES AND FUNCTIONS... 9 GETTING HELP IN MATLAB...

More information

Chapter 2 (Part 2) MATLAB Basics. dr.dcd.h CS 101 /SJC 5th Edition 1

Chapter 2 (Part 2) MATLAB Basics. dr.dcd.h CS 101 /SJC 5th Edition 1 Chapter 2 (Part 2) MATLAB Basics dr.dcd.h CS 101 /SJC 5th Edition 1 Display Format In the command window, integers are always displayed as integers Characters are always displayed as strings Other values

More information

Excel Tool: Calculations with Data Sets

Excel Tool: Calculations with Data Sets Excel Tool: Calculations with Data Sets The best thing about Excel for the scientist is that it makes it very easy to work with data sets. In this assignment, we learn how to do basic calculations that

More information

Part #1. A0B17MTB Matlab. Miloslav Čapek Filip Kozák, Viktor Adler, Pavel Valtr

Part #1. A0B17MTB Matlab. Miloslav Čapek Filip Kozák, Viktor Adler, Pavel Valtr A0B17MTB Matlab Part #1 Miloslav Čapek miloslav.capek@fel.cvut.cz Filip Kozák, Viktor Adler, Pavel Valtr Department of Electromagnetic Field B2-626, Prague You will learn Scalars, vectors, matrices (class

More information

Python lab session 1

Python lab session 1 Python lab session 1 Dr Ben Dudson, Department of Physics, University of York 28th January 2011 Python labs Before we can start using Python, first make sure: ˆ You can log into a computer using your username

More information

1 Introduction to Matlab

1 Introduction to Matlab 1 Introduction to Matlab 1. What is Matlab? Matlab is a computer program designed to do mathematics. You might think of it as a super-calculator. That is, once Matlab has been started, you can enter computations,

More information

A very brief Matlab introduction

A very brief Matlab introduction A very brief Matlab introduction Siniša Krajnović January 24, 2006 This is a very brief introduction to Matlab and its purpose is only to introduce students of the CFD course into Matlab. After reading

More information

Introduction to Programming

Introduction to Programming Introduction to Programming Department of Computer Science and Information Systems Tingting Han (afternoon), Steve Maybank (evening) tingting@dcs.bbk.ac.uk sjmaybank@dcs.bbk.ac.uk Autumn 2017 Week 4: More

More information

Julia Calculator ( Introduction)

Julia Calculator ( Introduction) Julia Calculator ( Introduction) Julia can replicate the basics of a calculator with the standard notations. Binary operators Symbol Example Addition + 2+2 = 4 Substraction 2*3 = 6 Multify * 3*3 = 9 Division

More information

Introduction to MATLAB

Introduction to MATLAB Outlines January 30, 2008 Outlines Part I: Part II: Writing MATLAB Functions Starting MATLAB Exiting MATLAB Getting Help Command Window Workspace Command History Current Directory Selector Real Values

More information

OO Fortran Exercises

OO Fortran Exercises OO Fortran Exercises Adrian Jackson February 27, 2018 Contents 1 Introduction 1 2 Getting going on ARCHER 2 2.1 Log into ARCHER frontend nodes and run commands............. 2 3 Introduction to Fortran

More information

Numerical Modelling in Fortran: day 2. Paul Tackley, 2017

Numerical Modelling in Fortran: day 2. Paul Tackley, 2017 Numerical Modelling in Fortran: day 2 Paul Tackley, 2017 Goals for today Review main points in online materials you read for homework http://www.cs.mtu.edu/%7eshene/courses/cs201/notes/intro.html More

More information

Experiment 1: Introduction to MATLAB I. Introduction. 1.1 Objectives and Expectations: 1.2 What is MATLAB?

Experiment 1: Introduction to MATLAB I. Introduction. 1.1 Objectives and Expectations: 1.2 What is MATLAB? Experiment 1: Introduction to MATLAB I Introduction MATLAB, which stands for Matrix Laboratory, is a very powerful program for performing numerical and symbolic calculations, and is widely used in science

More information

Mathworks (company that releases Matlab ) documentation website is:

Mathworks (company that releases Matlab ) documentation website is: 1 Getting Started The Mathematics Behind Biological Invasions Introduction to Matlab in UNIX Christina Cobbold and Tomas de Camino Beck as modified for UNIX by Fred Adler Logging in: This is what you do

More information

SOLVING SIMULTANEOUS EQUATIONS. Builtin rref(a) EXAMPLE E4.1 Solve Corresponding augmented matrix 2x 4y 2 a 242 x 3y 3

SOLVING SIMULTANEOUS EQUATIONS. Builtin rref(a) EXAMPLE E4.1 Solve Corresponding augmented matrix 2x 4y 2 a 242 x 3y 3 Lecture 4 matrices and progressions Open Lecture 4 on class website: www.math.hawaii.edu/190 ELEMENTARY ROW OPERATIONS swap mult add_mult Given a matri, there are three types of elementary row operations:

More information

MATLAB BASICS. < Any system: Enter quit at Matlab prompt < PC/Windows: Close command window < To interrupt execution: Enter Ctrl-c.

MATLAB BASICS. < Any system: Enter quit at Matlab prompt < PC/Windows: Close command window < To interrupt execution: Enter Ctrl-c. MATLAB BASICS Starting Matlab < PC: Desktop icon or Start menu item < UNIX: Enter matlab at operating system prompt < Others: Might need to execute from a menu somewhere Entering Matlab commands < Matlab

More information

This is a basic tutorial for the MATLAB program which is a high-performance language for technical computing for platforms:

This is a basic tutorial for the MATLAB program which is a high-performance language for technical computing for platforms: Appendix A Basic MATLAB Tutorial Extracted from: http://www1.gantep.edu.tr/ bingul/ep375 http://www.mathworks.com/products/matlab A.1 Introduction This is a basic tutorial for the MATLAB program which

More information

Object-Based Programming. Programming with Objects

Object-Based Programming. Programming with Objects ITEC1620 Object-Based Programming g Lecture 8 Programming with Objects Review Sequence, Branching, Looping Primitive datatypes Mathematical operations Four-function calculator Scientific calculator Don

More information

MATH (CRN 13695) Lab 1: Basics for Linear Algebra and Matlab

MATH (CRN 13695) Lab 1: Basics for Linear Algebra and Matlab MATH 495.3 (CRN 13695) Lab 1: Basics for Linear Algebra and Matlab Below is a screen similar to what you should see when you open Matlab. The command window is the large box to the right containing the

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab Eugeniy E. Mikhailov The College of William & Mary Lecture 02 Eugeniy Mikhailov (W&M) Practical Computing Lecture 02 1 / 27 Matlab variable types Eugeniy Mikhailov (W&M) Practical

More information

Lecturer: Keyvan Dehmamy

Lecturer: Keyvan Dehmamy MATLAB Tutorial Lecturer: Keyvan Dehmamy 1 Topics Introduction Running MATLAB and MATLAB Environment Getting help Variables Vectors, Matrices, and linear Algebra Mathematical Functions and Applications

More information

Why use MATLAB? Mathematcal computations. Used a lot for problem solving. Statistical Analysis (e.g., mean, min) Visualisation (1D-3D)

Why use MATLAB? Mathematcal computations. Used a lot for problem solving. Statistical Analysis (e.g., mean, min) Visualisation (1D-3D) MATLAB(motivation) Why use MATLAB? Mathematcal computations Used a lot for problem solving Statistical Analysis (e.g., mean, min) Visualisation (1D-3D) Signal processing (Fourier transform, etc.) Image

More information

What is MATLAB and howtostart it up?

What is MATLAB and howtostart it up? MAT rix LABoratory What is MATLAB and howtostart it up? Object-oriented high-level interactive software package for scientific and engineering numerical computations Enables easy manipulation of matrix

More information

Introduction to Computer Programming in Python Dr. William C. Bulko. Data Types

Introduction to Computer Programming in Python Dr. William C. Bulko. Data Types Introduction to Computer Programming in Python Dr William C Bulko Data Types 2017 What is a data type? A data type is the kind of value represented by a constant or stored by a variable So far, you have

More information

Creates a 1 X 1 matrix (scalar) with a value of 1 in the column 1, row 1 position and prints the matrix aaa in the command window.

Creates a 1 X 1 matrix (scalar) with a value of 1 in the column 1, row 1 position and prints the matrix aaa in the command window. EE 350L: Signals and Transforms Lab Spring 2007 Lab #1 - Introduction to MATLAB Lab Handout Matlab Software: Matlab will be the analytical tool used in the signals lab. The laboratory has network licenses

More information

You just told Matlab to create two strings of letters 'I have no idea what I m doing' and to name those strings str1 and str2.

You just told Matlab to create two strings of letters 'I have no idea what I m doing' and to name those strings str1 and str2. Chapter 2: Strings and Vectors str1 = 'this is all new to me' str2='i have no clue what I am doing' str1 = this is all new to me str2 = I have no clue what I am doing You just told Matlab to create two

More information

MATLAB Lesson I. Chiara Lelli. October 2, Politecnico di Milano

MATLAB Lesson I. Chiara Lelli. October 2, Politecnico di Milano MATLAB Lesson I Chiara Lelli Politecnico di Milano October 2, 2012 MATLAB MATLAB (MATrix LABoratory) is an interactive software system for: scientific computing statistical analysis vector and matrix computations

More information

Getting Started With Excel

Getting Started With Excel Chapter 1 Getting Started With Excel This chapter will familiarize you with various basic features of Excel. Specific features which you need to solve a problem will be introduced as the need arises. When

More information

A. Matrix-wise and element-wise operations

A. Matrix-wise and element-wise operations USC GSBME MATLAB CLASS Reviewing previous session Second session A. Matrix-wise and element-wise operations A.1. Matrix-wise operations So far we learned how to define variables and how to extract data

More information

AN INTRODUCTION TO MATLAB

AN INTRODUCTION TO MATLAB AN INTRODUCTION TO MATLAB 1 Introduction MATLAB is a powerful mathematical tool used for a number of engineering applications such as communication engineering, digital signal processing, control engineering,

More information

Codes and Coding. Objectives: Related Careers

Codes and Coding. Objectives: Related Careers Codes and Coding Objectives: 1. Students will become aware of several different programming code languages and be able to identify similarities and differences between them. 2. Students will learn how

More information

Introduction to FORTRAN

Introduction to FORTRAN Introduction to by Dr. Ibrahim A. Assakkaf Spring 2000 Department of Civil and Environmental Engineering University of Maryland Slide No. 1 Introduction = FORmula TRANslation Developed for the IBM 704

More information

Introduction to Scientific and Engineering Computing, BIL108E. Karaman

Introduction to Scientific and Engineering Computing, BIL108E. Karaman USING MATLAB INTRODUCTION TO SCIENTIFIC & ENGINEERING COMPUTING BIL 108E, CRN24023 To start from Windows, Double click the Matlab icon. To start from UNIX, Dr. S. Gökhan type matlab at the shell prompt.

More information

Overview (4) CPE 101 mod/reusing slides from a UW course. Assignment Statement: Review. Why Study Expressions? D-1

Overview (4) CPE 101 mod/reusing slides from a UW course. Assignment Statement: Review. Why Study Expressions? D-1 CPE 101 mod/reusing slides from a UW course Overview (4) Lecture 4: Arithmetic Expressions Arithmetic expressions Integer and floating-point (double) types Unary and binary operators Precedence Associativity

More information

Matlab Introduction. Scalar Variables and Arithmetic Operators

Matlab Introduction. Scalar Variables and Arithmetic Operators Matlab Introduction Matlab is both a powerful computational environment and a programming language that easily handles matrix and complex arithmetic. It is a large software package that has many advanced

More information

EP375 Computational Physics

EP375 Computational Physics EP375 Computational Physics Topic 1 MATLAB TUTORIAL BASICS Department of Engineering Physics University of Gaziantep Feb 2014 Sayfa 1 Basic Commands help command get help for a command clear all clears

More information

Dynamics and Vibrations Mupad tutorial

Dynamics and Vibrations Mupad tutorial Dynamics and Vibrations Mupad tutorial School of Engineering Brown University ENGN40 will be using Matlab Live Scripts instead of Mupad. You can find information about Live Scripts in the ENGN40 MATLAB

More information

Arithmetic and Logic Blocks

Arithmetic and Logic Blocks Arithmetic and Logic Blocks The Addition Block The block performs addition and subtractions on its inputs. This block can add or subtract scalar, vector, or matrix inputs. We can specify the operation

More information

INTRODUCTION TO DERIVE - by M. Yahdi

INTRODUCTION TO DERIVE - by M. Yahdi Math 111/112-Calculus I & II- Ursinus College INTRODUCTION TO DERIVE - by M. Yahdi This is a tutorial to introduce main commands of the Computer Algebra System DERIVE. You should do (outside of class)

More information

With the cursor flashing on the word FUNCTION, press the. Section 1. <MODE> key

With the cursor flashing on the word FUNCTION, press the. Section 1. <MODE> key 1 USING THE TI-89 A Primer for TI-83 Users (Easy Calculus Summer Assignment) Come to school on the first day with your TI-89. We will start school by learning calculus, so this assignment will help you

More information

How To Think Like A Computer Scientist, chapter 3; chapter 6, sections

How To Think Like A Computer Scientist, chapter 3; chapter 6, sections 6.189 Day 3 Today there are no written exercises. Turn in your code tomorrow, stapled together, with your name and the file name in comments at the top as detailed in the Day 1 exercises. Readings How

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB Basics MATLAB is a high-level interpreted language, and uses a read-evaluate-print loop: it reads your command, evaluates it, then prints the answer. This means it works a lot like

More information

Expressions. Eric Roberts Handout #3 CSCI 121 January 30, 2019 Expressions. Grace Murray Hopper. Arithmetic Expressions.

Expressions. Eric Roberts Handout #3 CSCI 121 January 30, 2019 Expressions. Grace Murray Hopper. Arithmetic Expressions. Eric Roberts Handout #3 CSCI 121 January 30, 2019 Expressions Grace Murray Hopper Expressions Eric Roberts CSCI 121 January 30, 2018 Grace Hopper was one of the pioneers of modern computing, working with

More information

CHAPTER 1 GETTING STARTED

CHAPTER 1 GETTING STARTED GETTING STARTED WITH EXCEL CHAPTER 1 GETTING STARTED Microsoft Excel is an all-purpose spreadsheet application with many functions. We will be using Excel 97. This guide is not a general Excel manual,

More information

Intrinsic Functions Outline

Intrinsic Functions Outline Intrinsic Functions Outline 1. Intrinsic Functions Outline 2. Functions in Mathematics 3. Functions in Fortran 90 4. A Quick Look at ABS 5. Intrinsic Functions in Fortran 90 6. Math: Domain Range 7. Programming:

More information

Getting started with RAPTOR [Adapted from by Dr. Wayne Brown]

Getting started with RAPTOR [Adapted from   by Dr. Wayne Brown] Getting started with RAPTOR [Adapted from https://raptor.martincarlisle.com/ by Dr. Wayne Brown] What is RAPTOR? RAPTOR is a visual programming development environment based on flowcharts. A flowchart

More information

1001ICT Introduction To Programming Lecture Notes

1001ICT Introduction To Programming Lecture Notes 1001ICT Introduction To Programming Lecture Notes School of Information and Communication Technology Griffith University Semester 1, 2015 1 M Environment console M.1 Purpose This environment supports programming

More information