Chapter 4 Branching Statements & Program Design

Size: px
Start display at page:

Download "Chapter 4 Branching Statements & Program Design"

Transcription

1 EGR115 Introduction to Computing for Engineers Branching Statements & Program Design from: S.J. Chapman, MATLAB Programming for Engineers, 5 th Ed Cengage Learning Topics Introduction: Program Design 4.1 Introduction to Top-Down Design Techniques 4.2 Use of Pseudocode 4.3 The Logical Data Type 4.4 Branches 4.5 More on Debugging MATLAB Programs

2 Slide 1 of 17 Introduction: Program Design Program Design So far, we developed simple MATLAB programs that were executed one after another in a fixed order: these programs are called sequential programs. Typically, these programs read input data, process it to produce desired results, and stop. As a next step in programming, we need to look at the ways to design and control the order in which statements are executed in a program. Two broad Categories of Program Code Structures 1. Branches: program code structures that are designed to execute selected specific sections of the code, based on specific logical conditions. (if and switch construct) 2. Loops: program code structures that are designed to repeat specific sections of the code, based on specific logical conditions. (while and for loops) Logical Data Type In order to construct and control branches and loops, we need to employ logical data types (true or false) for defining the logical conditions.

3 Slide 2 of Introduction to Top-Down Design Techniques Top-Down Design Process Develop: Pseudocode Convert: Pseudocode => MATLAB COMPILE MATLAB: Run/Debug Finished! Top-Down Program Design Top-down design is the process of starting with a large task and breaking it down into smaller, more easily understandable sub-tasks, which perform a portion of the desired task. Each sub-task may in turn be subdivided into smaller sub-tasks if necessary. Once the program is divided into small pieces, each piece can be coded and tested indepently. Traditional Program Design & Development Process 1. State the problem you are trying to solve/define required inputs and outputs 2. Design the algorithm 3. Convert algorithm into statements (compile) Repeat these processes (Debug) 4. Test Run the program MATLAB Program Design & Development Process 1. State the problem you are trying to solve/define required inputs and outputs 2. Develop MATLAB Pseudocode 3. Convert Pseudocode => MATLAB statements 4. Test Run/Debug (on the fly) <= no need to compile

4 Slide 3 of Use of Pseudocode EXAMPLE 4-1 (from EXAMPLE 2-4) Design a MATLAB program that reads an input temperature in degrees Fahrenheit, converts it to an absolute temperature in kelvin, and writes out the result. The relationship between temperature in degrees Fahrenheit (F) and temperature in kelvins (K) is: T 5 K F T 1. Prompt the user to enter an input temperature in F. 2. Read the input temperature. 3. Calculate the temperature in kelvin. 4. Write the result and stop. Let s create a simple Pseudocode for this example MATLAB Pseudocode A pseudocode is a conceptual algorithm to describe constructs (program structures). It is usually a hybrid mixture of MATLAB & English languages. It is structured like MATLAB (with a separate line for each distinct segment of code), but the descriptions on each line are written in English. You can just right click your computer s desktop, create a simple text file (new => text document) to get started (use notepad). Notepad MATLAB example_4_1.m 1. Prompt the user to enter an input temperature in degrees F 2. Read the input temperature temp_f <- input( Enter the temp in degrees F ) 3. Calculate the temperature in degrees K temp_k <- (5/9)*(temp_f 32) Write the result and stop fprintf (??? temp_f =??? temp_k) Next, the pseudocode is imported into MATLAB. Convert it to MATLAB script (m-file). Test run and debug in MATLAB (on the fly) using MATLAB symbolic debugger.

5 Slide 4 of Use of Pseudocode EXAMPLE 4-2 (from EXAMPLE 2-5) A voltage source V = 120 V with an internal resistance R S of 50 W is applied to a load of resistance R L. Find the value of load resistance R L that will result in the maximum possible power being supplied by the source to the load. How much power will be supplied in this case? Also, plot the power supplied to the load as a function of the load resistance R L. In this exercise, we need to vary the load resistance R L and compute the power supplied to the load at each value of R L. 2 The power supplied to the load resistance is given by: PL I RL where I is the current supplied to the load. The current supplied to the load can be calculated by Ohm s Law: V V I R R R TOT S L 1. Create an array of possible values for the load resistance. 2. Calculate the current for each value of R L. 3. Calculate the power supplied to the load. 4. Plot the power supplied to the load. Notepad MATLAB example_4_2.m 0. Must set the values of source voltage and internal resistance volts <- 120 / rs < Create an array of load resistances r1 <- from 1 to 100 with increment of 1 2. Calculate the current flow for each resistance amps <- volts/(rs+rl) 3. Calculate the power supplied to the load pl = (amps^2)*rl 4. Plot the power versus load resistance plot(rl,pl) with title, x&ylabels, grid

6 Slide 5 of The Logical Data Type Logical data type = true or false The Logical Data Type The logical data type is a special data that can have only two possible values (true or false). >> a1 = true; >> whos Command Window Name Size Bytes Class Attributes a1 1x1 1 logical If logical value is used in a place where a numerical value is expected, true is converted to 1 and false is converted to 0 (used as numerical values). Relational & Logical Operators Relational operators are operators that compare two numbers and produce a true or false result. Logical operators are operators that compare one or two logical values, and produce a true or false result. Command Window >> 3 < 4 Relational Operators ans = 1 (true) >> 3 <= 4 ans = 1 (true) >> 3 == 4 ans = 0 (false) >> 3 > 4 ans = 0 (false) >> 4 <= 4 ans = 1 (true) >> A < B ans = 1 (true)

7 Slide 6 of The Logical Data Type Logical data type = true or false Logical Operators Truth Tables for Logical Operations The general form of logic operations are: l1 op l2 op l1 Hierarchy of Operations 1. All arithmetic operators are evaluated first in the order previously described. 2. All relational operators (==, ~=, >, >=, <, <=) are evaluated, working from left to right. 3. All ~ operators are evaluated. 4. All & and && operators are evaluated, working from left to right. 5. All,, and xor operators are evaluated, working from left to right.

8 Slide 7 of The Logical Data Type EXAMPLE 4-3 Assuming that the following variables are initialized with the values shown, evaluate the result of the specified expressions: value1 = 1 value2 = 0 value3 = 1 value4 = -10 value5 = 0 value6 = [1 2; 0 1] (a)~value1 (b)~value3 (c)value1 value2 (d)value1 & value2 (e)value4 & value5 (f)~(value4 & value5) (g)value1 + value4 (h)value1 + (~value4) (i)value3 && value6 (j)value3 & value6 example_4_3.m example_4_3.m value1 = 1; value2 = 0; value3 = 1; value4 = -10; value5 = 0; value6 = [1 2; 0 1]; (a) a = ~value1 (b) b = ~value3 (c) c = value1 value2 (d) d = value1 & value2 (e) e = value4 & value5 (f) f = ~(value4 & value5) (g) g = value1 + value4 (h) h = value1 + (~value4) (i) i = value3 && value6 <= Illegal! (j) j = value3 & value6 >> example_4_3 a = 0 b = 0 c = 1 d = 0 e = 0 f = 1 g = -9 h = 1 j = NOTES) Command Window (i) The && operator must be used with scalar operands. (j) AND between a scalar and an array operand. The nonzero values of array value6 are treated as true (1).

9 Slide 8 of The Logical Data Type Do-It-Yourself (DIY) EXERCISE 4-1 Assuming that the following variables are initialized with the values shown, evaluate the result of the specified expressions: a = 20; b = -2; c = 0; d = 1; a = 2; b = ; 1. a > b 2. b > d 3. a > b && c > d 4. a == b 5. a && b > c 6. ~~b c = ; d = ; 7. ~(a > b) 8. a > c && b > c 9. c <= d 10. logical(d) 11. a * b > c 12. a * (b > c) exercise_4_1a.m Command Window exercise_4_1a.m a = 20; b = -2; c = 0; d = 1; ans1 = a > b ans2 = b > d ans3 = a > b && c > d ans4 = a == b ans5 = a && b > c ans6 = ~~b clear a = 2; b = [1-2; 0 10]; c = [0 1; 2 0]; d = [-2 1 2; 0 1 0]; ans7 = ~(a > b) ans8 = a > c && b > c <= Illegal! ans9 = c <= d <= Illegal! ans10 = logical(d) ans11 = a * b > c ans12 = a * (b > c) >> example_4_1a ans1 = 1 ans2 = 0 ans3 = 0 ans4 = 0 ans5 = 0 ans6 = 1 ans7 = ans10 = ans11 = ans12 = NOTES) (8) The && operator must be used with scalar operands. (9) Matrix dimensions must agree.

10 Slide 9 of The Logical Data Type Do-It-Yourself (DIY) EXERCISE 4-1 (continued) Assuming that the following variables are initialized with the values shown, evaluate the result of the specified expressions: a = 2; b = 3; c = 10; d = 0; a = 20; b = -2; c = 0; d = Test ; 13. a*b^2 > a*c 14. d b > a 15. (d b) > a 16. isinf(a/b) 17. isinf(a/c) 18. a > b && ischar(d) 19. isempty(c) 20. (~a) & b 21. (~a) + b Logical Functions exercise_4_1b.m Command Window exercise_4_1b.m a = 2; b = 3; c = 10; d = 0; ans13 = a > b ans14 = b > d ans15 = a > b && c > d clear a = 20; b = -2; c = 0; d = 'Test'; ans16 = isinf(a/b) ans17 = isinf(a/c) ans18 = a > b && ischar(d) ans19 = isempty(c) ans20 = (~a) & b ans21 = (~a) + b >> example_4_1b ans13 = 0 ans14 = 1 ans15 = 0 ans16 = 0 ans17 = 1 ans18 = 1 ans19 = 0 ans20 = 0 ans21 = -2

11 Slide 10 of Branches The if and switch Construct Branches Branches are MATLAB statements that permit us to select and execute specific sections of code (called blocks) while skipping other sections of code. There are two main construct types: (i) if construct and (ii) switch construct. The if Construct The control expressions (control_expr_1, control_expr_2,...) are logical expressions. If control_expr_1 is true, then the program executes the statements in Block 1, and skips to. Otherwise, the program checks for the status of control_expr_2. If control_expr_2 is true, then the program executes the statements in Block 2, and skips to. If all control expressions are zero (false), then the program executes the statements in the block associated with the clause. There can be any number of if clauses (0 or more) in an if construct, but there can be at most one clause. The switch Construct If the value of switch_expr is equal to case_expr_1, then the Block 1 will be executed, and the program will jump to. Similarly, if the value of switch_expr is equal to case_expr_2, then the Block 2 will be executed, and the program will jump to (and so forth). The code block otherwise is optional.

12 Slide 11 of Branches The if and switch Construct The try/catch Construct When a try/catch construct is reached, the statements in the try block will be executed. If no error occurs, the statements in the catch block will be skipped, and execution will continue. If an error occurs in the try block, the program will stop executing the statements in the try block, and immediately execute the statements in the catch block (then execution will continue). Flowchart (Block Diagram) Microsoft Word provides standard shapes with flowchart templates (Insert => Shapes => Flowchart). It is often quite effective to use flowchart, in order to understand how the program flows (visualizing sequences of program execution).

13 Slide 12 of Branches EXAMPLE 4-4 Write a program to solve for the roots of a quadratic equation, regardless of type. 2 (NOTE) the solution of the quadratic equation of the form of: ax bx c 0 can be given by: 2 b b 4ac x 2a MATLAB PSEUDOCODE if (b^2 4*a*c) < 0 Write msg that equation has two complex roots if (b^2 4*a*c) == 0 Write msg that equation has two identical real roots (means: b^2 4*a*c > 0, but no need to specify that) Write msg that equation has two distinct real roots calc_roots.m calc_roots.m disp ('This program solves for the roots of a quadratic '); disp ('equation of the form A*X^2 + B*X + C = 0. '); a = input ('Enter the coefficient A: '); b = input ('Enter the coefficient B: '); c = input ('Enter the coefficient C: '); Calculate discriminant discriminant = b^2-4 * a * c; Solve for the roots, deping on the value of the discriminant if discriminant > 0 there are two real roots, so... x1 = ( -b + sqrt(discriminant) ) / ( 2 * a ); x2 = ( -b - sqrt(discriminant) ) / ( 2 * a ); disp ('This equation has two real roots:'); fprintf ('x1 = f\n', x1); fprintf ('x2 = f\n', x2); if discriminant == 0 there is one repeated root, so... x1 = ( -b ) / ( 2 * a ); disp ('This equation has two identical real roots:'); fprintf ('x1 = x2 = f\n', x1); there are complex roots, so... real_part = ( -b ) / ( 2 * a ); imag_part = sqrt ( abs ( discriminant ) ) / ( 2 * a ); disp ('This equation has complex roots:'); fprintf('x1 = f +i f\n', real_part, imag_part ); fprintf('x1 = f -i f\n', real_part, imag_part );

14 Slide 13 of Branches EXAMPLE 4-5 Write a program to evaluate a function f (x, y) for any two user-specified values x and y. The function is defined as follows: MATLAB PSEUDOCODE f (x, y) = Input: x, y Output: f (x,y) Algorithm: 1. Read the input values of x and y 2. Calculate f (x, y) 3. Write out f (x, y) Prompt the user for the value x and y Read x and y (user keyboard inputs) if x >= 0 & y >= 0 function <- x + y if x >= 0 & y < 0 function <- x + y^2 if x < 0 & y >= 0 function <- x^2 + y function <- x^2 + y^2 Write out f(x,y) funxy.m Script file: funxy.m Prompt the user for the values x and y x = input ('Enter the x value: '); y = input ('Enter the y value: '); Calculate the function f(x,y) based upon the signs of x and y. if x >= 0 && y >= 0 fun = x + y; if x >= 0 && y < 0 fun = x + y^2; if x < 0 && y >= 0 fun = x^2 + y; fun = x^2 + y^2; Write the value of the function. disp (['The value of the function is ' num2str(fun)]);

15 multiple_if.m multiple_if.m grade = input('enter the score: '); if grade > 95 disp('the grade is A.') if grade >86 disp('the grade is B.') if grade >76 disp('the grade is C.') if grade >66 disp('the grade is D.') disp('the grade is F.') nested_if.m nested_if.m grade = input('enter the score: '); if grade > 95 disp('the grade is A.') if grade > 86 disp('the grade is B.') if grade > 76 disp('the grade is C.') if grade > 66 disp('the grade is D.') disp('the grade is F.')

16 exercise_4_2.m exercise_4_2.m part_select = input('select a, b, or c: ','s'); if part_select == 'a' (a) x = input('enter the value of x: '); if x >= 0 sqrt(x) error('negative SQRT error') if part_select == 'b' (b) numerator = input('enter the value of numerator: '); denominator = input('enter the value of denominator: '); if denominator >= 1.0E-300 numerator/denominator error('divide by zero error') if part_select == 'c' (c) miles = input('enter the miles: ') if miles <= 100 t_cost = 1.00 * miles a_cost = t_cost / miles if miles <= 200 t_cost = 1.00 * (100) * (miles - 100) a_cost = t_cost / miles t_cost = 1.00 * (100) * (200) * (miles - 300) a_cost = t_cost / miles error('input a, b, or c ONLY!')

17 exercise_4_3a.m exercise_4_3a.m volts = input('enter volts: '); if volts > 125 disp('warning: High voltage on line.') if volts < 105 disp('warning: High voltage on line.') disp('line voltage is within tolerances.') >> exercise_4_3a Error: At least one END is missing: the statement may begin here. exercise_4_3b.m exercise_4_3b.m NOTES) temperature = input('enter temperature: '); if temperature > 37 The script runs. However, if disp('human body temperature exceeded.') temperature is (for example) 110, if temperature > 100 this falls into true for both: disp('boiling point of water exceeded.') > 37 and > 100 Hence, it causes an error!

18 Debug a MATLAB Program MATLAB Code Analyzer The code analyzer provides an indicator in the top right of the MATLAB editor window. If the indicator is green, the analyzer did not detect code generation issues. If the indicator is red, the analyzer provides line by line error message with detailed explanations. Using the MATLAB The MATLAB editor provides many useful features for effective code development and debugging. FILE: new/open/save scripts & functions, find/compare files, and print files. NAVIGATE: Go To Line..., Set/Clear bookmarks, and find commands/words. EDIT: insert section, function, comment line and indent code. BREAKPOINTS: Set/Clear, Enable/Disable breakpoints and control error handling. RUN: run, run and advance, run section, and run and time. Publishing You can publish your MATLAB and Command Window in a single html file (and many other different publishing format style). PUBLISH => Publish

Chapter 2 MATLAB Basics

Chapter 2 MATLAB Basics EGR115 Introduction to Computing for Engineers MATLAB Basics from: S.J. Chapman, MATLAB Programming for Engineers, 5 th Ed. 2016 Cengage Learning Topics 2.1 Variables & Arrays 2.2 Creating & Initializing

More information

Chapter 8 Complex Numbers & 3-D Plots

Chapter 8 Complex Numbers & 3-D Plots EGR115 Introduction to Computing for Engineers Complex Numbers & 3-D Plots from: S.J. Chapman, MATLAB Programming for Engineers, 5 th Ed. 2016 Cengage Learning Topics Introduction: Complex Numbers & 3-D

More information

H.C. Chen 1/24/2019. Chapter 4. Branching Statements and Program Design. Programming 1: Logical Operators, Logical Functions, and the IF-block

H.C. Chen 1/24/2019. Chapter 4. Branching Statements and Program Design. Programming 1: Logical Operators, Logical Functions, and the IF-block Chapter 4 Branching Statements and Program Design Programming 1: Logical Operators, Logical Functions, and the IF-block Learning objectives: 1. Write simple program modules to implement single numerical

More information

Lecture 3 MATLAB programming (1) Dr.Qi Ying

Lecture 3 MATLAB programming (1) Dr.Qi Ying Lecture 3 MATLAB programming (1) Dr.Qi Ying Objectives Data types Logical operators/functions Branching Debugging of a program Data types in MATLAB Basic: Numeric (integer, floating-point, complex) Logical:

More information

Branches, Conditional Statements

Branches, Conditional Statements Branches, Conditional Statements Branches, Conditional Statements A conditional statement lets you execute lines of code if some condition is met. There are 3 general forms in MATLAB: if if/else if/elseif/else

More information

Files and File Management Scripts Logical Operations Conditional Statements

Files and File Management Scripts Logical Operations Conditional Statements Files and File Management Scripts Logical Operations Conditional Statements Files and File Management Matlab provides a group of commands to manage user files pwd: Print working directory displays the

More information

2.2 Creating & Initializing Variables in MATLAB

2.2 Creating & Initializing Variables in MATLAB 2.2 Creating & Initializing Variables in MATLAB Slide 5 of 27 Do-It-Yourself (DIY) EXERCISE 2-1 Answer the followings: (a) What is the difference between an array, a matrix, and a vector? (b) Let: c =

More information

Chapter 4: Programming with MATLAB

Chapter 4: Programming with MATLAB Chapter 4: Programming with MATLAB Topics Covered: Programming Overview Relational Operators and Logical Variables Logical Operators and Functions Conditional Statements For Loops While Loops Debugging

More information

Short Version of Matlab Manual

Short Version of Matlab Manual Short Version of Matlab Manual This is an extract from the manual which was used in MA10126 in first year. Its purpose is to refamiliarise you with the matlab programming concepts. 1 Starting MATLAB 1.1.1.

More information

C/C++ Programming for Engineers: Matlab Branches and Loops

C/C++ Programming for Engineers: Matlab Branches and Loops C/C++ Programming for Engineers: Matlab Branches and Loops John T. Bell Department of Computer Science University of Illinois, Chicago Review What is the difference between a script and a function in Matlab?

More information

EE 1105 Pre-lab 3 MATLAB - the ins and outs

EE 1105 Pre-lab 3 MATLAB - the ins and outs EE 1105 Pre-lab 3 MATLAB - the ins and outs INTRODUCTION MATLAB is a software tool used by engineers for wide variety of day to day tasks. MATLAB is available for UTEP s students via My Desktop. To access

More information

MATLAB MATLAB - Lecture # 8. Programming in MATLAB / Chapter 7. if end if-else end if-elseif-else end

MATLAB MATLAB - Lecture # 8. Programming in MATLAB / Chapter 7. if end if-else end if-elseif-else end MATLAB - Lecture # 8 Programming in MATLAB / Chapter 7 Topics Covered:. Relational and Logical Operators 2. Conditional statements. if if- if-if- INTRODUCTION TO PROGRAMMING 63-64 In a simple program the

More information

Physics 326G Winter Class 6

Physics 326G Winter Class 6 Physics 36G Winter 008 Class 6 Today we will learn about functions, and also about some basic programming that allows you to control the execution of commands in the programs you write. You have already

More information

Chapter 1 Introduction to MATLAB

Chapter 1 Introduction to MATLAB EGR115 Introduction to Computing for Engineers Introduction to MATLAB from: S.J. Chapman, MATLAB Programming for Engineers, 5 th Ed. 2016 Cengage Learning Topics Introduction: Computing for Engineers 1.1

More information

CSC 121 Spring 2017 Howard Rosenthal

CSC 121 Spring 2017 Howard Rosenthal CSC 121 Spring 2017 Howard Rosenthal Agenda To be able to define computer program, algorithm, and highlevel programming language. To be able to list the basic stages involved in writing a computer program.

More information

Math 230 Final Exam December 22, 2015

Math 230 Final Exam December 22, 2015 Math 230 Final Exam December 22, 2015 General Directions. This is an open- book, open- notes, open- computer test. However, you may not communicate with any person, except me, during the test. You have

More information

Chapter 7: Programming in MATLAB

Chapter 7: Programming in MATLAB The Islamic University of Gaza Faculty of Engineering Civil Engineering Department Computer Programming (ECIV 2302) Chapter 7: Programming in MATLAB 1 7.1 Relational and Logical Operators == Equal to ~=

More information

Programming in MATLAB Part 2

Programming in MATLAB Part 2 Programming in MATLAB Part 2 A computer program is a sequence of computer commands. In a simple program the commands are executed one after the other in the order they are typed. MATLAB provides several

More information

Lecture 9. Monday, January 31 CS 205 Programming for the Sciences - Lecture 9 1

Lecture 9. Monday, January 31 CS 205 Programming for the Sciences - Lecture 9 1 Lecture 9 Reminder: Programming Assignment 3 is due Wednesday by 4:30pm. Exam 1 is on Friday. Exactly like Prog. Assign. 2; no collaboration or help from the instructor. Log into Windows/ACENET. Start

More information

function [s p] = sumprod (f, g)

function [s p] = sumprod (f, g) Outline of the Lecture Introduction to M-function programming Matlab Programming Example Relational operators Logical Operators Matlab Flow control structures Introduction to M-function programming M-files:

More information

Structure Array 1 / 50

Structure Array 1 / 50 Structure Array A structure array is a data type that groups related data using data containers called fields. Each field can contain any type of data. Access data in a structure using dot notation of

More information

PSEUDOCODE AND FLOWCHARTS. Introduction to Programming

PSEUDOCODE AND FLOWCHARTS. Introduction to Programming PSEUDOCODE AND FLOWCHARTS Introduction to Programming What s Pseudocode? Artificial and Informal language Helps programmers to plan an algorithm Similar to everyday English Not an actual programming language

More information

ALGORITHMS AND FLOWCHARTS

ALGORITHMS AND FLOWCHARTS ALGORITHMS AND FLOWCHARTS ALGORITHMS AND FLOWCHARTS A typical programming task can be divided into two phases: Problem solving phase produce an ordered sequence of steps that describe solution of problem

More information

Attia, John Okyere. Control Statements. Electronics and Circuit Analysis using MATLAB. Ed. John Okyere Attia Boca Raton: CRC Press LLC, 1999

Attia, John Okyere. Control Statements. Electronics and Circuit Analysis using MATLAB. Ed. John Okyere Attia Boca Raton: CRC Press LLC, 1999 Attia, John Okyere. Control Statements. Electronics and Circuit Analysis using MATLAB. Ed. John Okyere Attia Boca Raton: CRC Press LLC, 1999 1999 by CRC PRESS LLC CHAPTER THREE CONTROL STATEMENTS 3.1 FOR

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

What is MATLAB? What is MATLAB? Programming Environment MATLAB PROGRAMMING. Stands for MATrix LABoratory. A programming environment

What is MATLAB? What is MATLAB? Programming Environment MATLAB PROGRAMMING. Stands for MATrix LABoratory. A programming environment What is MATLAB? MATLAB PROGRAMMING Stands for MATrix LABoratory A software built around vectors and matrices A great tool for numerical computation of mathematical problems, such as Calculus Has powerful

More information

Dr. Iyad Jafar. Adapted from the publisher slides

Dr. Iyad Jafar. Adapted from the publisher slides Computer Applications Lab Lab 5 Programming in Matlab Chapter 4 Sections 1,2,3,4 Dr. Iyad Jafar Adapted from the publisher slides Outline Program design and development Relational operators and logical

More information

Summary of the Lecture

Summary of the Lecture Summary of the Lecture 1 Introduction 2 MATLAB env., Variables, and format 3 4 5 MATLAB function, arrays and operations Algorithm and flowchart M-files: Script and Function Files 6 Structured Programming

More information

CS 199 Computer Programming. Spring 2018 Lecture 2 Problem Solving

CS 199 Computer Programming. Spring 2018 Lecture 2 Problem Solving CS 199 Computer Programming Spring 2018 Lecture 2 Problem Solving ALGORITHMS AND FLOWCHARTS A typical programming task can be divided into two phases: Problem solving phase produce an ordered sequence

More information

Can be put into the matrix form of Ax=b in this way:

Can be put into the matrix form of Ax=b in this way: Pre-Lab 0 Not for Grade! Getting Started with Matlab Introduction In EE311, a significant part of the class involves solving simultaneous equations. The most time efficient way to do this is through the

More information

Matlab and Octave: Quick Introduction and Examples 1 Basics

Matlab and Octave: Quick Introduction and Examples 1 Basics Matlab and Octave: Quick Introduction and Examples 1 Basics 1.1 Syntax and m-files There is a shell where commands can be written in. All commands must either be built-in commands, functions, names of

More information

Eng Marine Production Management. Introduction to Matlab

Eng Marine Production Management. Introduction to Matlab Eng. 4061 Marine Production Management Introduction to Matlab What is Matlab? Matlab is a commercial "Matrix Laboratory" package which operates as an interactive programming environment. Matlab is available

More information

4.0 Programming with MATLAB

4.0 Programming with MATLAB 4.0 Programming with MATLAB 4.1 M-files The term M-file is obtained from the fact that such files are stored with.m extension. M-files are alternative means of performing computations so as to expand MATLAB

More information

Dr. Khaled Al-Qawasmi

Dr. Khaled Al-Qawasmi Al-Isra University Faculty of Information Technology Department of CS Programming Mathematics using MATLAB 605351 Dr. Khaled Al-Qawasmi ١ Dr. Kahled Al-Qawasmi 2010-2011 Chapter 3 Selection Statements

More information

UNDERSTANDING PROBLEMS AND HOW TO SOLVE THEM BY USING COMPUTERS

UNDERSTANDING PROBLEMS AND HOW TO SOLVE THEM BY USING COMPUTERS UNDERSTANDING PROBLEMS AND HOW TO SOLVE THEM BY USING COMPUTERS INTRODUCTION TO PROBLEM SOLVING Introduction to Problem Solving Understanding problems Data processing Writing an algorithm CONTINUE.. Tool

More information

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

AP Computer Science Java Mr. Clausen Program 6A, 6B AP Computer Science Java Mr. Clausen Program 6A, 6B Program 6A LastNameFirstNameP6A (Quadratic Formula: 50 points) (Including complex or irrational roots) Write a program that begins by explaining the

More information

17 USING THE EDITOR AND CREATING PROGRAMS AND FUNCTIONS

17 USING THE EDITOR AND CREATING PROGRAMS AND FUNCTIONS 17 USING THE EDITOR AND CREATING PROGRAMS AND FUNCTIONS % Programs are kept in an m-file which is a series of commands kept in the file that is executed from MATLAB by typing the program (file) name from

More information

COMP 208 Computers in Engineering

COMP 208 Computers in Engineering COMP 208 Computers in Engineering Lecture 14 Jun Wang School of Computer Science McGill University Fall 2007 COMP 208 - Lecture 14 1 Review: basics of C C is case sensitive 2 types of comments: /* */,

More information

7 Control Structures, Logical Statements

7 Control Structures, Logical Statements 7 Control Structures, Logical Statements 7.1 Logical Statements 1. Logical (true or false) statements comparing scalars or matrices can be evaluated in MATLAB. Two matrices of the same size may be compared,

More information

ENGR 1181 MATLAB 09: For Loops 2

ENGR 1181 MATLAB 09: For Loops 2 ENGR 1181 MATLAB 09: For Loops Learning Objectives 1. Use more complex ways of setting the loop index. Construct nested loops in the following situations: a. For use with two dimensional arrays b. For

More information

5. Selection: If and Switch Controls

5. Selection: If and Switch Controls Computer Science I CS 135 5. Selection: If and Switch Controls René Doursat Department of Computer Science & Engineering University of Nevada, Reno Fall 2005 Computer Science I CS 135 0. Course Presentation

More information

Fundamentals of Programming (Python) Getting Started with Programming

Fundamentals of Programming (Python) Getting Started with Programming Fundamentals of Programming (Python) Getting Started with Programming Ali Taheri Sharif University of Technology Some slides have been adapted from Python Programming: An Introduction to Computer Science

More information

CS 221 Lecture. Tuesday, 4 October There are 10 kinds of people in this world: those who know how to count in binary, and those who don t.

CS 221 Lecture. Tuesday, 4 October There are 10 kinds of people in this world: those who know how to count in binary, and those who don t. CS 221 Lecture Tuesday, 4 October 2011 There are 10 kinds of people in this world: those who know how to count in binary, and those who don t. Today s Agenda 1. Announcements 2. You Can Define New Functions

More information

Relational and Logical Statements

Relational and Logical Statements Relational and Logical Statements Relational Operators in MATLAB A operator B A and B can be: Variables or constants or expressions to compute Scalars or arrays Numeric or string Operators: > (greater

More information

CSE/NEUBEH 528 Homework 0: Introduction to Matlab

CSE/NEUBEH 528 Homework 0: Introduction to Matlab CSE/NEUBEH 528 Homework 0: Introduction to Matlab (Practice only: Do not turn in) Okay, let s begin! Open Matlab by double-clicking the Matlab icon (on MS Windows systems) or typing matlab at the prompt

More information

Chapter 11 Input/Output (I/O) Functions

Chapter 11 Input/Output (I/O) Functions EGR115 Introduction to Computing for Engineers Input/Output (I/O) Functions from: S.J. Chapman, MATLAB Programming for Engineers, 5 th Ed. 2016 Cengage Learning Topics Introduction: MATLAB I/O 11.1 The

More information

Introduction to programming in MATLAB

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

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

LAB 2: Linear Equations and Matrix Algebra. Preliminaries

LAB 2: Linear Equations and Matrix Algebra. Preliminaries Math 250C, Section C2 Hard copy submission Matlab # 2 1 Revised 07/13/2016 LAB 2: Linear Equations and Matrix Algebra In this lab you will use Matlab to study the following topics: Solving a system of

More information

Functions of Two Variables

Functions of Two Variables Functions of Two Variables MATLAB allows us to work with functions of more than one variable With MATLAB 5 we can even move beyond the traditional M N matrix to matrices with an arbitrary number of dimensions

More information

SECTION 2: PROGRAMMING WITH MATLAB. MAE 4020/5020 Numerical Methods with MATLAB

SECTION 2: PROGRAMMING WITH MATLAB. MAE 4020/5020 Numerical Methods with MATLAB SECTION 2: PROGRAMMING WITH MATLAB MAE 4020/5020 Numerical Methods with MATLAB 2 Functions and M Files M Files 3 Script file so called due to.m filename extension Contains a series of MATLAB commands The

More information

Computers and FORTRAN Language Fortran 95/2003. Dr. Isaac Gang Tuesday March 1, 2011 Lecture 3 notes. Topics:

Computers and FORTRAN Language Fortran 95/2003. Dr. Isaac Gang Tuesday March 1, 2011 Lecture 3 notes. Topics: Computers and FORTRAN Language Fortran 95/2003 Dr. Isaac Gang Tuesday March 1, 2011 Lecture 3 notes Topics: - Program Design - Logical Operators - Logical Variables - Control Statements Any FORTRAN program

More information

Getting Started with Python

Getting Started with Python Fundamentals of Programming (Python) Getting Started with Python Sina Sajadmanesh Sharif University of Technology Some slides have been adapted from Python Programming: An Introduction to Computer Science

More information

Programming for Experimental Research. Flow Control

Programming for Experimental Research. Flow Control Programming for Experimental Research Flow Control FLOW CONTROL In a simple program, the commands are executed one after the other in the order they are typed. Many situations require more sophisticated

More information

Question. Insight Through

Question. Insight Through Intro Math Problem Solving October 10 Question about Accuracy Rewrite Square Root Script as a Function Functions in MATLAB Road Trip, Restaurant Examples Writing Functions that Use Lists Functions with

More information

Programming in MATLAB

Programming in MATLAB 2. Scripts, Input/Output and if Faculty of mathematics, physics and informatics Comenius University in Bratislava October 7th, 2015 Scripts Scripts script is basically just a sequence of commands the same

More information

Math 98 - Introduction to MATLAB Programming. Fall Lecture 1

Math 98 - Introduction to MATLAB Programming. Fall Lecture 1 Syllabus Instructor: Chris Policastro Class Website: https://math.berkeley.edu/~cpoli/math98/fall2016.html See website for 1 Class Number 2 Oce hours 3 Textbooks 4 Lecture schedule slides programs Syllabus

More information

An Introduction to MATLAB Programming

An Introduction to MATLAB Programming An Introduction to MATLAB Programming Center for Interdisciplinary Research and Consulting Department of Mathematics and Statistics University of Maryland, Baltimore County www.umbc.edu/circ Winter 2008

More information

BRANCHING if-else statements

BRANCHING if-else statements BRANCHING if-else statements Conditional Statements A conditional statement lets us choose which statement t t will be executed next Therefore they are sometimes called selection statements Conditional

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

2. MATLAB Basics Cengage Learning. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.

2. MATLAB Basics Cengage Learning. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. MATLAB Programming for Engineers 5th Edition Chapman Solutions Manual Full Download: http://testbanklive.com/download/matlab-programming-for-engineers-5th-edition-chapman-solutions-manual/ 2. MATLAB Basics

More information

Maltepe University Computer Engineering Department. Algorithms and Programming. Chapter 4: Conditionals - If statement - Switch statement

Maltepe University Computer Engineering Department. Algorithms and Programming. Chapter 4: Conditionals - If statement - Switch statement Maltepe University Computer Engineering Department Algorithms and Programming Chapter 4: Conditionals - If statement - Switch statement Control Structures in C Control structures control the flow of execution

More information

A QUICK INTRODUCTION TO MATLAB. Intro to matlab getting started

A QUICK INTRODUCTION TO MATLAB. Intro to matlab getting started A QUICK INTRODUCTION TO MATLAB Very brief intro to matlab Intro to matlab getting started Basic operations and a few illustrations This set is indepent from rest of the class notes. Matlab will be covered

More information

Linear, Quadratic, Exponential, and Absolute Value Functions

Linear, Quadratic, Exponential, and Absolute Value Functions Linear, Quadratic, Exponential, and Absolute Value Functions Linear Quadratic Exponential Absolute Value Y = mx + b y = ax 2 + bx + c y = a b x y = x 1 What type of graph am I? 2 What can you tell me about

More information

PLD Semester Exam Study Guide Dec. 2018

PLD Semester Exam Study Guide Dec. 2018 Covers material from Chapters 1-8. Semester Exam will be built from these questions and answers, though they will be re-ordered and re-numbered and possibly worded slightly differently than on this study

More information

Algebra II Quadratic Functions

Algebra II Quadratic Functions 1 Algebra II Quadratic Functions 2014-10-14 www.njctl.org 2 Ta b le o f C o n te n t Key Terms click on the topic to go to that section Explain Characteristics of Quadratic Functions Combining Transformations

More information

Selection Statements. Chapter 4. Copyright 2013 Elsevier Inc. All rights reserved 1

Selection Statements. Chapter 4. Copyright 2013 Elsevier Inc. All rights reserved 1 Selection Statements Chapter 4 Copyright 2013 Elsevier Inc. All rights reserved 1 Recall Relational Expressions The relational operators in MATLAB are: > greater than < less than >= greater than or equals

More information

ECE 202 LAB 3 ADVANCED MATLAB

ECE 202 LAB 3 ADVANCED MATLAB Version 1.2 1 of 13 BEFORE YOU BEGIN PREREQUISITE LABS ECE 201 Labs EXPECTED KNOWLEDGE ECE 202 LAB 3 ADVANCED MATLAB Understanding of the Laplace transform and transfer functions EQUIPMENT Intel PC with

More information

CS111: PROGRAMMING LANGUAGE1. Lecture 2: Algorithmic Problem Solving

CS111: PROGRAMMING LANGUAGE1. Lecture 2: Algorithmic Problem Solving CS111: PROGRAMMING LANGUAGE1 Lecture 2: Algorithmic Problem Solving Agenda 2 Problem Solving Techniques Pseudocode Algorithm Flow charts Examples How People Solve Problems 3 A Problem exists when what

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

MATH 2650/ Intro to Scientific Computation - Fall Lab 1: Starting with MATLAB. Script Files

MATH 2650/ Intro to Scientific Computation - Fall Lab 1: Starting with MATLAB. Script Files MATH 2650/3670 - Intro to Scientific Computation - Fall 2017 Lab 1: Starting with MATLAB. Script Files Content - Overview of Course Objectives - Use of MATLAB windows; the Command Window - Arithmetic operations

More information

Programming in MATLAB

Programming in MATLAB Programming in MATLAB Scripts, functions, and control structures Some code examples from: Introduction to Numerical Methods and MATLAB Programming for Engineers by Young & Mohlenkamp Script Collection

More information

Introduction to. The Help System. Variable and Memory Management. Matrices Generation. Interactive Calculations. Vectors and Matrices

Introduction to. The Help System. Variable and Memory Management. Matrices Generation. Interactive Calculations. Vectors and Matrices Introduction to Interactive Calculations Matlab is interactive, no need to declare variables >> 2+3*4/2 >> V = 50 >> V + 2 >> V Ans = 52 >> a=5e-3; b=1; a+b Most elementary functions and constants are

More information

Truth Table! Review! Use this table and techniques we learned to transform from 1 to another! ! Gate Diagram! Today!

Truth Table! Review! Use this table and techniques we learned to transform from 1 to another! ! Gate Diagram! Today! CS61C L17 Combinational Logic Blocks and Intro to CPU Design (1)! inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 17 Combinational Logic Blocks and Intro to CPU Design 2010-07-20!!!Instructor

More information

Chapter 4: Making Decisions. Copyright 2012 Pearson Education, Inc. Sunday, September 7, 14

Chapter 4: Making Decisions. Copyright 2012 Pearson Education, Inc. Sunday, September 7, 14 Chapter 4: Making Decisions 4.1 Relational Operators Relational Operators Used to compare numbers to determine relative order Operators: > Greater than < Less than >= Greater than or equal to

More information

FONDAMENTI DI INFORMATICA. Prof. Emiliano Casalicchio

FONDAMENTI DI INFORMATICA. Prof. Emiliano Casalicchio FONDAMENTI DI INFORMATICA Prof. Emiliano Casalicchio casalicchio@ing.uniroma2.it 13/04/2015 Fondamenti di Informatica a.a. 2014/15 - E. Casalicchio 2 Objectives of this lesson We ll discuss Code blocks

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

COMPUTER SKILLS LESSON 12. Valeria Cardellini A.Y. 2015/16

COMPUTER SKILLS LESSON 12. Valeria Cardellini A.Y. 2015/16 COMPUTER SKILLS LESSON 12 Valeria Cardellini cardellini@ing.uniroma2.it A.Y. 2015/16 11/25/15 Computer Skills - Lesson 12 - V. Cardellini 2 Objectives of this lesson We ll discuss Functions that return

More information

PROGRAM DESIGN TOOLS. Algorithms, Flow Charts, Pseudo codes and Decision Tables. Designed by Parul Khurana, LIECA.

PROGRAM DESIGN TOOLS. Algorithms, Flow Charts, Pseudo codes and Decision Tables. Designed by Parul Khurana, LIECA. PROGRAM DESIGN TOOLS Algorithms, Flow Charts, Pseudo codes and Decision Tables Introduction The various tools collectively referred to as program design tools, that helps in planning the program are:-

More information

Computer Science & Engineering 150A Problem Solving Using Computers

Computer Science & Engineering 150A Problem Solving Using Computers Computer Science & Engineering 150A Problem Solving Using Computers Lecture 04 - Conditionals Stephen Scott (Adapted from Christopher M. Bourke) Fall 2009 1 / 1 cbourke@cse.unl.edu Control Structure Conditions

More information

BIOE 198MI Biomedical Data Analysis. Spring Semester 2019 Lab 1b. Matrices, arrays, m-files, I/O, custom functions

BIOE 198MI Biomedical Data Analysis. Spring Semester 2019 Lab 1b. Matrices, arrays, m-files, I/O, custom functions BIOE 198MI Biomedical Data Analysis. Spring Semester 2019 Lab 1b. Matrices, arrays, m-files, I/O, custom functions A. Scalars, vectors, and matrices versus arrays and the associated syntax In terms of

More information

MATLAB INTRODUCTION. Matlab can be used interactively as a super hand calculator, or, more powerfully, run using scripts (i.e., programs).

MATLAB INTRODUCTION. Matlab can be used interactively as a super hand calculator, or, more powerfully, run using scripts (i.e., programs). L A B 6 M A T L A B MATLAB INTRODUCTION Matlab is a commercial product that is used widely by students and faculty and researchers at UTEP. It provides a "high-level" programming environment for computing

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

5. Control Statements

5. Control Statements 5. Control Statements This section of the course will introduce you to the major control statements in C++. These control statements are used to specify the branching in an algorithm/recipe. Control statements

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

Introduction to Computer Programming for Non-Majors

Introduction to Computer Programming for Non-Majors Introduction to Computer Programming for Non-Majors CSC 2301, Fall 2015 Chapter 7 Part 1 The Department of Computer Science Objectives 2 To understand the programming pattern simple decision and its implementation

More information

CE890 / ENE801 Lecture 1 Introduction to MATLAB

CE890 / ENE801 Lecture 1 Introduction to MATLAB CE890 / ENE801 Lecture 1 Introduction to MATLAB CE890: Course Objectives Become familiar with a powerful tool for computations and visualization (MATLAB) Promote problem-solving skills using computers

More information

Lecture 3: Array Applications, Cells, Structures & Script Files

Lecture 3: Array Applications, Cells, Structures & Script Files Lecture 3: Array Applications, Cells, Structures & Script Files Dr. Mohammed Hawa Electrical Engineering Department University of Jordan EE201: Computer Applications. See Textbook Chapter 2 and Chapter

More information

SNS COLLEGE OF ENGINEERING,

SNS COLLEGE OF ENGINEERING, SNS COLLEGE OF ENGINEERING, COIMBATORE Department of Computer Science and Engineering QUESTION BANK(PART A) GE8151 - PROBLEM SOLVING AND PYTHON PROGRAMMING TWO MARKS UNIT-I 1. What is computer? Computers

More information

Matlab Programming Introduction 1 2

Matlab Programming Introduction 1 2 Matlab Programming Introduction 1 2 Mili I. Shah August 10, 2009 1 Matlab, An Introduction with Applications, 2 nd ed. by Amos Gilat 2 Matlab Guide, 2 nd ed. by D. J. Higham and N. J. Higham Starting Matlab

More information

Programming 1. Script files. help cd Example:

Programming 1. Script files. help cd Example: Programming Until now we worked with Matlab interactively, executing simple statements line by line, often reentering the same sequences of commands. Alternatively, we can store the Matlab input commands

More information

- HALF YEARLY EXAM ANSWER KEY DEC-2016 COMPUTER SCIENCE ENGLISH MEDIUM

- HALF YEARLY EXAM ANSWER KEY DEC-2016 COMPUTER SCIENCE ENGLISH MEDIUM www.padasalai.net - HALF YEARLY EXAM ANSWER KEY DEC-2016 COMPUTER SCIENCE ENGLISH MEDIUM 1 A 26 D 51 C 2 C 27 D 52 D 3 C 28 C 53 B 4 A 29 B 54 D 5 B 30 B 55 B 6 A 31 C 56 A 7 B 32 C 57 D 8 C 33 B 58 C

More information

Control Structures. Lecture 4 COP 3014 Fall September 18, 2017

Control Structures. Lecture 4 COP 3014 Fall September 18, 2017 Control Structures Lecture 4 COP 3014 Fall 2017 September 18, 2017 Control Flow Control flow refers to the specification of the order in which the individual statements, instructions or function calls

More information

Yimin Math Centre. Year 10 Term 2 Homework. 3.1 Graphs in the number plane The minimum and maximum value of a quadratic function...

Yimin Math Centre. Year 10 Term 2 Homework. 3.1 Graphs in the number plane The minimum and maximum value of a quadratic function... Year 10 Term 2 Homework Student Name: Grade: Date: Score: Table of contents 3 Year 10 Term 2 Week 3 Homework 1 3.1 Graphs in the number plane................................. 1 3.1.1 The parabola....................................

More information

Laboratory 1 Octave Tutorial

Laboratory 1 Octave Tutorial Signals, Spectra and Signal Processing Laboratory 1 Octave Tutorial 1.1 Introduction The purpose of this lab 1 is to become familiar with the GNU Octave 2 software environment. 1.2 Octave Review All laboratory

More information

Engineering 12 - Spring, 1999

Engineering 12 - Spring, 1999 Engineering 12 - Spring, 1999 1. (18 points) A portion of a C program is given below. Fill in the missing code to calculate and display a table of n vs n 3, as shown below: 1 1 2 8 3 27 4 64 5 125 6 216

More information

MATLAB - Lecture # 4

MATLAB - Lecture # 4 MATLAB - Lecture # 4 Script Files / Chapter 4 Topics Covered: 1. Script files. SCRIPT FILE 77-78! A script file is a sequence of MATLAB commands, called a program.! When a file runs, MATLAB executes the

More information

A Brief Introduction to MATLAB

A Brief Introduction to MATLAB A Brief Introduction to MATLAB MATLAB (Matrix Laboratory) is an interactive software system for numerical computations and graphics. As the name suggests, MATLAB was first designed for matrix computations:

More information

Page 1 of 7 E7 Spring 2009 Midterm I SID: UNIVERSITY OF CALIFORNIA, BERKELEY Department of Civil and Environmental Engineering. Practice Midterm 01

Page 1 of 7 E7 Spring 2009 Midterm I SID: UNIVERSITY OF CALIFORNIA, BERKELEY Department of Civil and Environmental Engineering. Practice Midterm 01 Page 1 of E Spring Midterm I SID: UNIVERSITY OF CALIFORNIA, BERKELEY Practice Midterm 1 minutes pts Question Points Grade 1 4 3 6 4 16 6 1 Total Notes (a) Write your name and your SID on the top right

More information

A QUICK INTRODUCTION TO MATLAB

A QUICK INTRODUCTION TO MATLAB A QUICK INTRODUCTION TO MATLAB Very brief intro to matlab Basic operations and a few illustrations This set is independent from rest of the class notes. Matlab will be covered in recitations and occasionally

More information