ENGR 1181 Midterm Exam 2: Study Guide and Practice Problems

Size: px
Start display at page:

Download "ENGR 1181 Midterm Exam 2: Study Guide and Practice Problems"

Transcription

1 ENGR 1181 Midterm Exam 2: Study Guide and Practice Problems Disclaimer Problems seen in this study guide may resemble problems relating mainly to the pertinent homework assignments. Reading this study guide and solving the practice problems is not a sufficient level of studying for this exam. Students should also review the relevant reading material and PowerPoint slides as questions will be asked from those places as well. 50 Points Total Exam Specifications 15 points multiple choice (~15 questions, 1 2 pts. each) o Done on Carmen using a lockdown browser o No other internet access is allowed. Those accessing the internet otherwise will be sent to COAM. Please review OSU s policy on academic misconduct. o Graded automatically and entered into Carmen. 35 points 2 show your work problems o Both problems will focus on MATLAB, you may need to fill in the blanks with code, or create a script file, or modify a script file. Always start your script files by displaying your name, seat number etc. and using close all; clear; clc o Make sure you assign a different name for each PDF file during the exam. o Do not use run section during the exam, it will not save your script file and your work will be lost! ALWAYS use run. Calculators are not allowed. The exam is closed book closed notes. No communication with other students is allowed. Please review OSU s policy on academic misconduct. No use of cell phones.

2 Content Review Below is contained the content and learning objectives that will be tested on this exam. Not all learning objectives will be tested exactly as read, however students should use this material to keep track of what they need to be reviewing. 1. MATLAB a. Array Creation i. [a, b, c ; d, e, f] notation ii. [min : step : max] notation iii. linspace function iv. I/O Demonstrate proper usage of basic MATLAB features (e.g., the Command Window, script files, other default windows, arithmetic operations, assigning variables and names, built in functions, help command) Demonstrate proper notation for accessing elements from previously assigned one dimensional arrays (e.g., single elements, list of elements) and two dimensional arrays (e.g., those with rows and columns) b. Array Accessing i. Pure array accessing ii. Sub arrays iii. Using the colon operator Demonstrate proper notation for accessing elements from previously assigned one dimensional arrays (e.g., single elements, list of elements) and two dimensional arrays (e.g., those with rows and columns) Explain that a string is a one dimensional array and can be used the same way as numeric arrays c. Array Operations (. Operators) Explain meaning of element by element operations Identify situations where the standard operators in MATLAB (when used with arrays) are reserved for linear algebra, which is not always element byelement Apply dot operators for o The six cases where linear algebra is not element by element and therefore dot operators are needed to produce element by element calculations d. MATLAB algebra syntax (conversion from math expression) Explain meaning of element by element operations

3 Identify need to translate mathematical notation into proper MATLAB syntax e. Conditional Statements and logical operators Explain how conditional statements (e.g., if end, if else end, switch case) are used to make decisions Apply logical operations correctly in arrays Analyze data using logical operators. f. MATLAB looping Use more complex ways of setting the loop index Use loops to repeat a code with conditional statements 2. Labs continued a. Solar Meter Describe and build both a calibration and solar meter circuit Convert decimal values to binary values Compare a pictorial image of a circuit to a schematic wiring diagram b. Solar Cell Identify the advantages and disadvantages of solar cells. Calculate the efficiency of a solar cell. c. Beam Bending Employ the concepts of stress, strain, and Young's modulus for structural materials. Use the stress strain equation to calculate how applied forces deform structures. Calculate the moment of inertia of various beam geometries. Determine how beam geometry affects the stiffness and strength of beams. Identify unknown beam material through analysis and calculation of Young s Modulus. Evaluate behavior of various beams based on material and shape. d. Wind Turbine part A Describe the relationship between velocity (of the wind) and pressure based on Bernoulli s Equation for incompressible flow. Calculate the power available in the wind and compare it to the power generated by a wind turbine. Summarize the characteristics of the wind tunnel and turbine. Describe the relationship between velocity (of the wind) and pressure.

4 Determine the power available in the wind. Relate the power available in the wind to the wind speed. Compare the power generated by a wind turbine to the power in the wind. Here is a syntax guide for help in reviewing. PRINTING AND BRINGING THIS TO THE EXAM IS NOT ALLOWED. MatLab Syntax Review Sheet FOR MIDTERM 2 RELEVANT INFORMATION ONLY Current Directory your current working directory with a list of m files Workspace current list of MatLab variables and values Command History past commands that have been typed and executed Command Window where commands can be entered Editor Window where you write and run MatLab script files Don t forget that typing help into MATLAB will assist you with specific functions and is allowed during the exam show your work problems! MatLab Tips >> clc clear command window; does not clear memory >> cmd displays the result of a command in the command window >> cmd; does not display the result in the command window >> cmd1, cmd2 displays both results >> cmd1; cmd2 displays last result only clear clear x,y,z variable names math precedence... (ellipsis) up arrow down arrow clears ALL variables from memory clears only x, y, and z 1. must begin with a letter 2. are case sensitive 3. contain letters, numbers, and _ highest ( ) ; ^ ; * / ; + lowest extends a command to the next line scrolls backward through previous commands scrolls forward through commands help abcd help on the subject "abcd" ( doc abcd works too )

5 Numeric Display Formats format short format long format short e format bank nnn.1234 nnn (14 decimal places) n.1234e+001 nnn.12 Input / Output Commands disp( ' any text ' ) fprintf('text = %i,%f',k,x) x = input( ' any text ' ) displays ' any text ' in the command window formatted output prints "Text = integer and fixed point" asks the user to enter a value for x from the keyboard 1 D Array (row and column vectors) scalar, s is a single number (a 1 x 1 array) vector, v is a 1 row x n column array a list of numbers v_list = [ a b c ] or = [ a, b, c ] row vector v_row = [ a b c ] or = [ a, b, c ] column vector v_col = [ a ; b ; c ] constant spacing v_space = [ first : space : last ] single spacing v_1space = [ first : last ] vector with n terms, evenly spaced v_nterms = linspace( first, last, n ) transpose of a vector v_col = v_row ' value of the ith term v(i) Addition / Subtraction z = x y z = [,, Multiplication / Division z = x.* y and z = x. / y Exponents z = x.^ y z = [.^,.^,.] max(v) or min (v) length(v) mean(v) or sum(v) Returns largest / smallest element of v Returns the length (# of elements) in vector v Returns average value / sum of elements in v 2 D Array (matrix) Matrix, A is an r (rows) X c (columns) array A( r, c ) is the value of the element ( r, c ) in A A( r, c ), in rows A = [ row1 ; row2 ; row3 ] A( r1:r2, c1:c2 ) retrieves values in row and column ranges Example: A(1:3, [1 4 6]) means rows 1 3 and columns 1,4,6 of matrix A

6 Logic Conditional and Relational Operators Less than / Greater than < / > Less than equal to / greater than equal to <= / >= Equal to / Not equal to == / ~= TRUE statement / FALSE statement 1 (or any non zero number) / 0 & AND ( Example: A & B ) TRUE when A and B are both true OR ( Example: A B ) TRUE when either A is true or B is true ~ NOT ( Example: ~ A ) TRUE if A is false / FALSE if A is true Operator precedence ( high low ) ( ) ^ ~ */ + > < >= <= == ~= & Conditional Statements if ( conditional statement) Command Group end Works when there is only one command group if ( conditional statement) Command Group 1 else Command Group 2 end if ( conditional 1 ) Command Group 1 elseif ( conditional 2 ) Command Group 2 elseif ( conditional 3 ) Command Group 3 else Command Group 4 end If the conditional statement is "True", then do "Command Group 1". It the conditional statement is "False", then do "Command Group 2". "If elseif elseif else end" When there are more than two command groups, you can use this form with elseif Elseif = if not the first, do the second, or if not the second, do the third, etc. The "else" never has a conditional and is optional.

7 Loops k = first : step : last Loop index variable = first value : step size : last value Example of a loop in a script file: v1 = [ 0 : 5 : 25 ] ; % Define the vector v1 This loop calculates a new vector v2 from an existing vector v1. Note that the loop uses vector addressing. for i = 1 : length (v1) % The step size is 1 v2(i) = v1(i) ^ 2 ; % calculates a new element in the vector v2 end disp(v2) Common Functions sqrt(x) exp(x) abs(x) log(x) log10(x) factorial(x) sin(x) / cos(x) / tan(x) sind(x) / cosd(x) / tand(x) round(x) fix(x) ceil(x) floor(x) rem(x,y) if rem(x,y) == 0 sign(x) square root of x = exponential function absolute value of x natural log of x log base 10 of x factorial function [ x! ], where x is a positive integer trig functions with angle in radians trig functions with angle in degrees Round to the nearest integer Round toward zero Round toward infinity Round toward negative infinity Equals the remainder of x divided by y Conditional test that is true when x is a multiple of y Signum function returns [1 if x>0], [ 1 if x<0], [0 if x=0]

8 ENGR 1181 Midterm 2 Review Worksheet Note: This practice material does not contain actual test questions or represent the format of the midterm. The first 29 questions should be completed WITHOUT using MATLAB. 1) Answer the following questions according to the screen shot of MATLAB below: a. Label all 6 items (Command Window, Editor Window, etc ) b. What is the primary purpose of the Workspace? What is stored there? c. If a data file does not appear in #2, is it readily available to load into MATLAB?

9 2) Is Hello ENGR 1181 Student.m an acceptable file name for an.m file? If not, how could we modify it so that it is? 3) True or False, it is good practice to define all of the variables you need for a script file directly in the Command Window before you run your code. TRUE FALSE 4) What will MATLAB Output for entering the following in the Command Window? y=5(3)+2 5) What command clears the MATLAB workspace of all variables? 6) Given the variable pi= is defined in your workspace, how would you write one line of code to reference this variable and display: To the command window? The value of pi is ) Given the code below: k=0; for i = 1:3 end k k= 1+k+i;

10 What value of k will be displayed in the command window? 8) Given the list of variable names below, determine whether they would be good practice to use in MATLAB (or if they even work). If not, briefly explain why: a. The_greatest_variable_name b. J.T. Barret c. mean d. length e. 2manyloveENGR1181 f. time 9) Write 1 line of code that prompts the user to input their name as a string, and stores it to the variable name : 10) Write 1 line of code that creates an array v that starts at the value 2, goes to 100, and has 195 data points in between.

11 11) Write 1 line of code that creates an array u that starts at a value of 7 and goes to the value 27 with increments of 2. 12) What is the last value of the array X generated by the command below? X = (1:2:8) 13) Given the array A, answer the following questions: A= [ ] a. Write one line of code that extracts the first four elements of A: b. Write one line of code that extracts the 5, 6, and 9 th elements of A and assigns them to the variable B: c. Write one line of code that extracts the odd elements of A and assigns them to the variable Odd: 14) Given the matrix M below, answer the following questions: a. Write one line of code that extracts the last two rows, and all the columns of M:

12 b. Write one line of code that extracts all the rows, and the odd columns of M: c. Write one line of code that extracts rows 1 2 and 4, and all the even columns of M and stores it to the variable C: d. Write one line of code that extracts the even rows and columns 3 and 4 of M: 15) Given the code below, what will be the value of z when the for loop is complete? Y = linspace(1,10,1200); for z = 1:length(Y) q = 1 + 1; end z 16) Based on the code below, what will be displayed to the Command Window once the script has run? t = 3; d = 1; While t < 10 end t d t = t+2; d = d+1;

13 17) Compare and contrast for loops and while loops. When might it be better to use one over the other? 18) Write a command that starts a timer called tstart 19) What is 1 line of code that will check the time of the timer tstart 20) The modulus of elasticity is defined as: a) The ratio of yield stress to strain (y s /ε) in the plastic region. b) The slope of strain to stress (ε/σ) in the elastic region. c) The slope of stress to strain (σ/ε) in the elastic region. d) The ratio of stress to strain (σ/ε) in the plastic region. e) The slope of stress to material stiffness (σ/e) in the elastic region. 21) Write the command to create a vector, X, starting at 50 and ending at 5 with values every 0.2, which displays the created vector in the command window.

14 22) What is the command to use a built in system function to find the average of the vector X from question #1 above, assign the value to RESULT, and suppress output in the command window? 23) If C = [ ] and D = [7 8 9], what is the command to create a single row array X with the elements of C and D (afterwards X = [ ])? 24) Write the command to find the sine of 30? 25) The Solar Meter Lab used a Trim Pot (Trim Potentiometer) in the breadboard setup. When you turn the knob on the TrimPot, which variable is adjusted? 26) Given that x=[ ; ; ] has been assigned, what would be the result of y=x(2:3,[1 2 4])? 27) Write a single statement that prompts the user with 'Please enter the day of the week: ' Assign the results to a variable called 'today', suppressing any outputs to Command Window. 28) Given a 10 by 3 matrix M, write a single command that extracts all members of the 3 rd column of matrix M and assigns it to a vector called M_col_3 using the colon operator. 29) A vector x is defined in MATLAB by: x = [1:2:7]; Consider the equation: y Write a MATLAB command that creates a vector y where each element has a value calculated by the equation with the corresponding element in the vector x.

15 ENGR 1181 Exam 2 Show Your Work Review You are being assigned two problems. Complete each problem in a separate script file. Include comment statements to help organize your script file and try to implement flexible coding. Include the standard header. Problem 1 Background You are an engineer who loves to play pranks at the office. Your co worker has MATLAB up on the screen, and has exited their cubical to go to the restroom your time to strike. Problem Statement Given your Halloween spirit, you want to make it appear as if a ghost is typing on their screen. In this problem, prompt the user to enter the message they want to *magically* appear on their coworker s screen. After inputting the command, clear the Command Window. Utilizing a for loop and a new function called the pause()command, have the program type out the sentence in the command window one character at a time. Once the program is finished, display the total elapsed time the program took to run in the command window. HINT: In the command window, enter doc pause for more information on the pause command. IMPORTANT: You will NOT be responsible for knowing the pause() command for the upcoming midterm. It is simply being used as a tool to complete this problem. Problem 2 Background Environmental Engineers often take measurements of large data sets to analyze how conditions of a system are being impacted by a population or concentration value. This could apply to many difference facets, wildlife population, chemical contamination, etc Problem Statement PART 1 You are an environmental engineer who needs to analyze duck population data of Mirror Lake in order to put together an ecology report. Your main goal is to find out on average how many ducks were on the pond each year. You have obtained a file called duck_data.txt that records the year (column 1) and the rounded average number of ducks in the Mirror Lake for that year (column 2) from

16 In a script file, develop a program that can analyze the years from Extract two vectors and name them as duck and year. Keep in mind that these values were generated off of measurements in the field. PART 2 Your coworker left you with the formula that estimates the number of Crested Ducks per year (Y) as a function of the average number of ducks per that year (X): (NOTE: Afroduck is a Crested duck, google it!).3.2 Using array extraction and a for loop calculate the average of the number of Crested Ducks on Mirror lake from (1 value). Communicate this result to the command window using fprintf(). NOTE: means floor the values within the brackets

ENGR 1181c Midterm Exam 2: Study Guide and Practice Problems

ENGR 1181c Midterm Exam 2: Study Guide and Practice Problems ENGR 1181c Midterm Exam 2: Study Guide and Practice Problems Disclaimer Problems seen in this study guide may resemble problems relating mainly to the pertinent homework assignments. Reading this study

More information

ENGR 1181 Autumn 2015 Final Exam Study Guide and Practice Problems

ENGR 1181 Autumn 2015 Final Exam Study Guide and Practice Problems ENGR 1181 Autumn 2015 Final Exam Study Guide and Practice Problems Disclaimer Problems seen in this study guide may resemble problems relating mainly to the pertinent homework assignments. Reading this

More information

No, not unless you specify in MATLAB which folder directory to look for it in, which is outside of the scope of this course.

No, not unless you specify in MATLAB which folder directory to look for it in, which is outside of the scope of this course. ENGR 1181 Midterm 2 Review Worksheet SOLUTIONS Note: This practice material does not contain actual test questions or represent the format of the midterm. The first 29 questions should be completed WITHOUT

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

Quick MATLAB Syntax Guide

Quick MATLAB Syntax Guide Quick MATLAB Syntax Guide Some useful things, not everything if-statement Structure: if (a = = = ~=

More information

Welcome to EGR 106 Foundations of Engineering II

Welcome to EGR 106 Foundations of Engineering II Welcome to EGR 106 Foundations of Engineering II Course information Today s specific topics: Computation and algorithms MATLAB Basics Demonstrations Material in textbook chapter 1 Computation What is computation?

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

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

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

Introduction to MATLAB

Introduction to MATLAB ELG 3125 - Lab 1 Introduction to MATLAB TA: Chao Wang (cwang103@site.uottawa.ca) 2008 Fall ELG 3125 Signal and System Analysis P. 1 Do You Speak MATLAB? MATLAB - The Language of Technical Computing ELG

More information

9 Using Equation Networks

9 Using Equation Networks 9 Using Equation Networks In this chapter Introduction to Equation Networks 244 Equation format 247 Using register address lists 254 Setting up an enable contact 255 Equations displayed within the Network

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

PART 1 PROGRAMMING WITH MATHLAB

PART 1 PROGRAMMING WITH MATHLAB PART 1 PROGRAMMING WITH MATHLAB Presenter: Dr. Zalilah Sharer 2018 School of Chemical and Energy Engineering Universiti Teknologi Malaysia 23 September 2018 Programming with MATHLAB MATLAB Environment

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. 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

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

What is a Function? EF102 - Spring, A&S Lecture 4 Matlab Functions

What is a Function? EF102 - Spring, A&S Lecture 4 Matlab Functions What is a Function? EF102 - Spring, 2002 A&S Lecture 4 Matlab Functions What is a M-file? Matlab Building Blocks Matlab commands Built-in commands (if, for, ) Built-in functions sin, cos, max, min Matlab

More information

ANSI C Programming Simple Programs

ANSI C Programming Simple Programs ANSI C Programming Simple Programs /* This program computes the distance between two points */ #include #include #include main() { /* Declare and initialize variables */ double

More information

Consider this m file that creates a file that you can load data into called rain.txt

Consider this m file that creates a file that you can load data into called rain.txt SAVING AND IMPORTING DATA FROM A DATA FILES AND PROCESSING AS A ONE DIMENSIONAL ARRAY If we save data in a file sequentially than we can call it back sequentially into a row vector. Consider this m file

More information

Numerical Analysis First Term Dr. Selcuk CANKURT

Numerical Analysis First Term Dr. Selcuk CANKURT ISHIK UNIVERSITY FACULTY OF ENGINEERING and DEPARTMENT OF COMPUTER ENGINEERING Numerical Analysis 2017-2018 First Term Dr. Selcuk CANKURT selcuk.cankurt@ishik.edu.iq Textbook Main Textbook MATLAB for Engineers,

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

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

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

Introduction to MatLab. Introduction to MatLab K. Craig 1

Introduction to MatLab. Introduction to MatLab K. Craig 1 Introduction to MatLab Introduction to MatLab K. Craig 1 MatLab Introduction MatLab and the MatLab Environment Numerical Calculations Basic Plotting and Graphics Matrix Computations and Solving Equations

More information

Boolean Logic & Branching Lab Conditional Tests

Boolean Logic & Branching Lab Conditional Tests I. Boolean (Logical) Operations Boolean Logic & Branching Lab Conditional Tests 1. Review of Binary logic Three basic logical operations are commonly used in binary logic: and, or, and not. Table 1 lists

More information

To start using Matlab, you only need be concerned with the command window for now.

To start using Matlab, you only need be concerned with the command window for now. Getting Started Current folder window Atop the current folder window, you can see the address field which tells you where you are currently located. In programming, think of it as your current directory,

More information

Chapter 4: Basic C Operators

Chapter 4: Basic C Operators Chapter 4: Basic C Operators In this chapter, you will learn about: Arithmetic operators Unary operators Binary operators Assignment operators Equalities and relational operators Logical operators Conditional

More information

Chapter 3. built in functions help feature elementary math functions data analysis functions random number functions computational limits

Chapter 3. built in functions help feature elementary math functions data analysis functions random number functions computational limits Chapter 3 built in functions help feature elementary math functions data analysis functions random number functions computational limits I have used resources for instructors, available from the publisher

More information

Chapter 2. MATLAB Basis

Chapter 2. MATLAB Basis Chapter MATLAB Basis Learning Objectives:. Write simple program modules to implement single numerical methods and algorithms. Use variables, operators, and control structures to implement simple sequential

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

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 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

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

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

1. Register an account on: using your Oxford address

1. Register an account on:   using your Oxford  address 1P10a MATLAB 1.1 Introduction MATLAB stands for Matrix Laboratories. It is a tool that provides a graphical interface for numerical and symbolic computation along with a number of data analysis, simulation

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 MATLAB. Computational Probability and Statistics CIS 2033 Section 003

Introduction to MATLAB. Computational Probability and Statistics CIS 2033 Section 003 Introduction to MATLAB Computational Probability and Statistics CIS 2033 Section 003 About MATLAB MATLAB (MATrix LABoratory) is a high level language made for: Numerical Computation (Technical computing)

More information

One-dimensional Array

One-dimensional Array One-dimensional Array ELEC 206 Prof. Siripong Potisuk 1 Defining 1-D Array Also known as a vector A list of numbers arranged in a row row vector or a column column vector A scalar variable is a one-element

More information

MATLAB Tutorial EE351M DSP. Created: Thursday Jan 25, 2007 Rayyan Jaber. Modified by: Kitaek Bae. Outline

MATLAB Tutorial EE351M DSP. Created: Thursday Jan 25, 2007 Rayyan Jaber. Modified by: Kitaek Bae. Outline MATLAB Tutorial EE351M DSP Created: Thursday Jan 25, 2007 Rayyan Jaber Modified by: Kitaek Bae Outline Part I: Introduction and Overview Part II: Matrix manipulations and common functions Part III: Plots

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

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

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

A Short Introduction to Matlab

A Short Introduction to Matlab A Short Introduction to Matlab Sheng Xu & Daniel Reynolds SMU Mathematics, 2015 1 What is Matlab? Matlab is a computer language with many ready-to-use powerful and reliable algorithms for doing numerical

More information

Introduction to MATLAB for Engineers, Third Edition

Introduction to MATLAB for Engineers, Third Edition PowerPoint to accompany Introduction to MATLAB for Engineers, Third Edition William J. Palm III Chapter 2 Numeric, Cell, and Structure Arrays Copyright 2010. The McGraw-Hill Companies, Inc. This work is

More information

Introduction to PartSim and Matlab

Introduction to PartSim and Matlab NDSU Introduction to PartSim and Matlab pg 1 PartSim: www.partsim.com Introduction to PartSim and Matlab PartSim is a free on-line circuit simulator that we use in Circuits and Electronics. It works fairly

More information

6-1 (Function). (Function) !*+!"#!, Function Description Example. natural logarithm of x (base e) rounds x to smallest integer not less than x

6-1 (Function). (Function) !*+!#!, Function Description Example. natural logarithm of x (base e) rounds x to smallest integer not less than x (Function) -1.1 Math Library Function!"#! $%&!'(#) preprocessor directive #include !*+!"#!, Function Description Example sqrt(x) square root of x sqrt(900.0) is 30.0 sqrt(9.0) is 3.0 exp(x) log(x)

More information

Process Optimization

Process Optimization Process Optimization Tier II: Case Studies Section 1: Lingo Optimization Software Optimization Software Many of the optimization methods previously outlined can be tedious and require a lot of work to

More information

2.0 MATLAB Fundamentals

2.0 MATLAB Fundamentals 2.0 MATLAB Fundamentals 2.1 INTRODUCTION MATLAB is a computer program for computing scientific and engineering problems that can be expressed in mathematical form. The name MATLAB stands for MATrix LABoratory,

More information

Arithmetic. 2.2.l Basic Arithmetic Operations. 2.2 Arithmetic 37

Arithmetic. 2.2.l Basic Arithmetic Operations. 2.2 Arithmetic 37 2.2 Arithmetic 37 This is particularly important when programs are written by more than one person. It may be obvious to you that cv stands for can volume and not current velocity, but will it be obvious

More information

Introduction to MATLAB for Numerical Analysis and Mathematical Modeling. Selis Önel, PhD

Introduction to MATLAB for Numerical Analysis and Mathematical Modeling. Selis Önel, PhD Introduction to MATLAB for Numerical Analysis and Mathematical Modeling Selis Önel, PhD Advantages over other programs Contains large number of functions that access numerical libraries (LINPACK, EISPACK)

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

Math 340 Fall 2014, Victor Matveev. Binary system, round-off errors, loss of significance, and double precision accuracy.

Math 340 Fall 2014, Victor Matveev. Binary system, round-off errors, loss of significance, and double precision accuracy. Math 340 Fall 2014, Victor Matveev Binary system, round-off errors, loss of significance, and double precision accuracy. 1. Bits and the binary number system A bit is one digit in a binary representation

More information

EGR 111 Introduction to MATLAB

EGR 111 Introduction to MATLAB EGR 111 Introduction to MATLAB This lab introduces the MATLAB help facility, shows how MATLAB TM, which stands for MATrix LABoratory, can be used as an advanced calculator. This lab also introduces assignment

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

Introduction to MATLAB Practical 1

Introduction to MATLAB Practical 1 Introduction to MATLAB Practical 1 Daniel Carrera November 2016 1 Introduction I believe that the best way to learn Matlab is hands on, and I tried to design this practical that way. I assume no prior

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

1) As a logical statement, is 1 considered true or false in MATLAB? Explain your answer.

1) As a logical statement, is 1 considered true or false in MATLAB? Explain your answer. ENGR 1181 Midterm 2+ Review Note: This practice material does not contain actual test questions or represent the format of the final. The first 20 questions should be completed WITHOUT using MATLAB. This

More information

Digital Image Analysis and Processing CPE

Digital Image Analysis and Processing CPE Digital Image Analysis and Processing CPE 0907544 Matlab Tutorial Dr. Iyad Jafar Outline Matlab Environment Matlab as Calculator Common Mathematical Functions Defining Vectors and Arrays Addressing Vectors

More information

ELEC4042 Signal Processing 2 MATLAB Review (prepared by A/Prof Ambikairajah)

ELEC4042 Signal Processing 2 MATLAB Review (prepared by A/Prof Ambikairajah) Introduction ELEC4042 Signal Processing 2 MATLAB Review (prepared by A/Prof Ambikairajah) MATLAB is a powerful mathematical language that is used in most engineering companies today. Its strength lies

More information

Engineering Problem Solving with C++, Etter/Ingber

Engineering Problem Solving with C++, Etter/Ingber Engineering Problem Solving with C++, Etter/Ingber Chapter 2 Simple C++ Programs C++, Second Edition, J. Ingber 1 Simple C++ Programs Program Structure Constants and Variables C++ Operators Standard Input

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

Chapter 2. Outline. Simple C++ Programs

Chapter 2. Outline. Simple C++ Programs Chapter 2 Simple C++ Programs Outline Objectives 1. Building C++ Solutions with IDEs: Dev-cpp, Xcode 2. C++ Program Structure 3. Constant and Variables 4. C++ Operators 5. Standard Input and Output 6.

More information

Programming in MATLAB

Programming in MATLAB trevor.spiteri@um.edu.mt http://staff.um.edu.mt/trevor.spiteri Department of Communications and Computer Engineering Faculty of Information and Communication Technology University of Malta 17 February,

More information

2 Making Decisions. Store the value 3 in memory location y

2 Making Decisions. Store the value 3 in memory location y 2.1 Aims 2 Making Decisions By the end of this worksheet, you will be able to: Do arithmetic Start to use FORTRAN intrinsic functions Begin to understand program flow and logic Know how to test for zero

More information

MATLAB Basics. Configure a MATLAB Package 6/7/2017. Stanley Liang, PhD York University. Get a MATLAB Student License on Matworks

MATLAB Basics. Configure a MATLAB Package 6/7/2017. Stanley Liang, PhD York University. Get a MATLAB Student License on Matworks MATLAB Basics Stanley Liang, PhD York University Configure a MATLAB Package Get a MATLAB Student License on Matworks Visit MathWorks at https://www.mathworks.com/ It is recommended signing up with a student

More information

2.Simplification & Approximation

2.Simplification & Approximation 2.Simplification & Approximation As we all know that simplification is most widely asked topic in almost every banking exam. So let us try to understand what is actually meant by word Simplification. Simplification

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab Kristian Sandberg Department of Applied Mathematics University of Colorado Goal The goal with this worksheet is to give a brief introduction to the mathematical software Matlab.

More information

WHOLE NUMBER AND DECIMAL OPERATIONS

WHOLE NUMBER AND DECIMAL OPERATIONS WHOLE NUMBER AND DECIMAL OPERATIONS Whole Number Place Value : 5,854,902 = Ten thousands thousands millions Hundred thousands Ten thousands Adding & Subtracting Decimals : Line up the decimals vertically.

More information

ENGR Fall Exam 1

ENGR Fall Exam 1 ENGR 1300 Fall 01 Exam 1 INSTRUCTIONS: Duration: 60 minutes Keep your eyes on your own work! Keep your work covered at all times! 1. Each student is responsible for following directions. Read carefully..

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB Dr./ Ahmed Nagib Mechanical Engineering department, Alexandria university, Egypt Sep 2015 Chapter 5 Functions Getting Help for Functions You can use the lookfor command to find functions

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

Scientific Computing with MATLAB

Scientific Computing with MATLAB Scientific Computing with MATLAB Dra. K.-Y. Daisy Fan Department of Computer Science Cornell University Ithaca, NY, USA UNAM IIM 2012 2 Focus on computing using MATLAB Computer Science Computational Science

More information

CT 229 Java Syntax Continued

CT 229 Java Syntax Continued CT 229 Java Syntax Continued 06/10/2006 CT229 Lab Assignments Due Date for current lab assignment : Oct 8 th Before submission make sure that the name of each.java file matches the name given in the assignment

More information

Lesson #3. Variables, Operators, and Expressions. 3. Variables, Operators and Expressions - Copyright Denis Hamelin - Ryerson University

Lesson #3. Variables, Operators, and Expressions. 3. Variables, Operators and Expressions - Copyright Denis Hamelin - Ryerson University Lesson #3 Variables, Operators, and Expressions Variables We already know the three main types of variables in C: int, char, and double. There is also the float type which is similar to double with only

More information

Introduction to Matlab

Introduction to Matlab NDSU Introduction to Matlab pg 1 Becoming familiar with MATLAB The console The editor The graphics windows The help menu Saving your data (diary) Solving N equations with N unknowns Least Squares Curve

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

ME 142 Engineering Computation I. Unit 1.2 Excel Functions

ME 142 Engineering Computation I. Unit 1.2 Excel Functions ME 142 Engineering Computation I Unit 1.2 Excel Functions TOA Make sure to submit TOA If not submitted, will receive score of 0 Common Questions from 1.1 & 1.2 Named Cell PP 1.1.2 Name cell B2 Payrate

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 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

TECH TIP VISION Calibration and Data Acquisition Software

TECH TIP VISION Calibration and Data Acquisition Software TECH TIP VISION Calibration and Data Acquisition Software May 2016 Using Calculated Channels in VISION Calculated channels are data items created in a Recorder file whose values are calculated from other

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

ENGR Fall Exam 1

ENGR Fall Exam 1 ENGR 13100 Fall 2012 Exam 1 INSTRUCTIONS: Duration: 60 minutes Keep your eyes on your own work! Keep your work covered at all times! 1. Each student is responsible for following directions. Read carefully.

More information

Integer Operations. Summer Packet 7 th into 8 th grade 1. Name = = = = = 6.

Integer Operations. Summer Packet 7 th into 8 th grade 1. Name = = = = = 6. Summer Packet 7 th into 8 th grade 1 Integer Operations Name Adding Integers If the signs are the same, add the numbers and keep the sign. 7 + 9 = 16-2 + -6 = -8 If the signs are different, find the difference

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

Introduction. Matlab for Psychologists. Overview. Coding v. button clicking. Hello, nice to meet you. Variables

Introduction. Matlab for Psychologists. Overview. Coding v. button clicking. Hello, nice to meet you. Variables Introduction Matlab for Psychologists Matlab is a language Simple rules for grammar Learn by using them There are many different ways to do each task Don t start from scratch - build on what other people

More information

EL2310 Scientific Programming

EL2310 Scientific Programming Lecture 4: Programming in Matlab Yasemin Bekiroglu (yaseminb@kth.se) Florian Pokorny(fpokorny@kth.se) Overview Overview Lecture 4: Programming in Matlab Wrap Up More on Scripts and Functions Wrap Up Last

More information

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

Introduction to MATLAB 7 for Engineers

Introduction to MATLAB 7 for Engineers PowerPoint to accompany Introduction to MATLAB 7 for Engineers William J. Palm III Chapter 2 Numeric, Cell, and Structure Arrays Copyright 2005. The McGraw-Hill Companies, Inc. Permission required for

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

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

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

Maths Functions User Manual

Maths Functions User Manual Professional Electronics for Automotive and Motorsport 6 Repton Close Basildon Essex SS13 1LE United Kingdom +44 (0) 1268 904124 info@liferacing.com www.liferacing.com Maths Functions User Manual Document

More information

Methods CSC 121 Fall 2014 Howard Rosenthal

Methods CSC 121 Fall 2014 Howard Rosenthal Methods CSC 121 Fall 2014 Howard Rosenthal Lesson Goals Understand what a method is in Java Understand Java s Math Class Learn the syntax of method construction Learn both void methods and methods that

More information

Class #15: Experiment Introduction to Matlab

Class #15: Experiment Introduction to Matlab Class #15: Experiment Introduction to Matlab Purpose: The objective of this experiment is to begin to use Matlab in our analysis of signals, circuits, etc. Background: Before doing this experiment, students

More information

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

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 LECTURE 1: ARITHMETIC AND FUNCTIONS MATH 190 WEBSITE: www.math.hawaii.edu/ gautier/190.html PREREQUISITE: You must have taken or be taking Calculus I concurrently. If not taken here, specify the college

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

Ordinary Differential Equation Solver Language (ODESL) Reference Manual

Ordinary Differential Equation Solver Language (ODESL) Reference Manual Ordinary Differential Equation Solver Language (ODESL) Reference Manual Rui Chen 11/03/2010 1. Introduction ODESL is a computer language specifically designed to solve ordinary differential equations (ODE

More information

MATLAB TUTORIAL WORKSHEET

MATLAB TUTORIAL WORKSHEET MATLAB TUTORIAL WORKSHEET What is MATLAB? Software package used for computation High-level programming language with easy to use interactive environment Access MATLAB at Tufts here: https://it.tufts.edu/sw-matlabstudent

More information

CME 192: Introduction to Matlab

CME 192: Introduction to Matlab CME 192: Introduction to Matlab Matlab Basics Brett Naul January 15, 2015 Recap Using the command window interactively Variables: Assignment, Identifier rules, Workspace, command who and whos Setting the

More information

ENGR 1181 MATLAB 02: Array Creation

ENGR 1181 MATLAB 02: Array Creation ENGR 1181 MATLAB 02: Array Creation Learning Objectives: Students will read Chapter 2.1 2.4 of the MATLAB book before coming to class. This preparation material is provided to supplement this reading.

More information