ENG 1181 College of Engineering Engineering Education Innovation Center MATLAB is a powerful program for numerical computations, plotting and programming.

Slides:



Advertisements
Similar presentations
Introduction to Applications & Basic Features. What is MATLAB®? MATLAB® /Simulink® is a powerful software tool for: Performing mathematical computations.
Advertisements

Computer Programming w/ Eng. Applications
ENG 1181 College of Engineering Engineering Education Innovation Center Microsoft Excel: Data Analysis Trendlines Formulas Functions Cell Addressing.
Lab1 (Signal & System) Instructor: Anan Osothsilp Date: 30 Jan 07.
EGR 106 – Week 2 – Arrays & Scripts Brief review of last week Arrays: – Concept – Construction – Addressing Scripts and the editor Audio arrays Textbook.
Introduction to MATLAB 7 for Engineers
Division Example 2x - 3y + 4z = 10 x + 6y - 3z = 4 -5x + y + 2z = 3 A*X = B where A = B = >> X = A\B X =
Introduction to MATLAB
Introduction to MATLAB ENGR 1187 MATLAB 1. Programming In The Real World Programming is a powerful tool for solving problems in every day industry settings.
4. Week 04.March Use of M-File Editor/Debugger: text editor, debugger; editor works with file types in addition to.m (MATLAB “m-files”)
EG280 - CS for Engineers Chapter 2, Introduction to C Part I Topics: Program structure Constants and variables Assignment Statements Standard input and.
THE MATLAB ENVIRONMENT VARIABLES BASIC COMMANDS HELP HP 100 – MATLAB Wednesday, 8/27/2014
MATLAB Tutorials Session I Introduction to MATLAB Rajeev Madazhy Dept of Mechanical Engineering LSU.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
1 Lab of COMP 406 Teaching Assistant: Pei-Yuan Zhou Contact: Lab 1: 12 Sep., 2014 Introduction of Matlab (I)
MEGN 536 – Computational Biomechanics MATLAB: Getting Started Prof. Anthony J. Petrella Computational Biomechanics Group.
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
Introduction to MATLAB ENGR 1181 MATLAB 1. Programming In The Real World Programming is a powerful tool for solving problems in every day industry settings.
Introduction to Engineering MATLAB – 1 Introduction to MATLAB Agenda Introduction Arithmetic Operations MATLAB Windows Command Window Defining Variables.
EECE 360/460 Matlab Tutorial Jan Outline What is Matlab? What is Matlab? Matlab Interface Matlab Interface Basic Syntax Basic Syntax Plotting Graphs.
Release Numbers MATLAB is updated regularly The Mathworks packages their software in groups, called releases, New releases are issued twice a year in the.
Slide deck by Dr. Greg Reese Miami University MATLAB An Introduction With Applications, 5 th Edition Dr. Amos Gilat The Ohio State University Chapter 1.
Introduction to Engineering MATLAB – 6 Script Files - 1 Agenda Script files.
Chapter 1: Getting Started with MATLAB MATLAB for Scientist and Engineers Using Symbolic Toolbox.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
Introduction to Engineering MATLAB – 2 Introduction to MATLAB - 2 Agenda Defining Variables MATLAB Windows.
CMPS 1371 Introduction to Computing for Engineers MatLab.
10/24/20151 Chapter 2 Review: MATLAB Environment Introduction to MATLAB 7 Engineering 161.
Introduction to Programming with RAPTOR
MATLAB Technical Computing Environment. MATLAB Matlab is an interactive computing environment that enables numerical computation and data visualization.
Introduction to MATLAB ENGR 1181 MATLAB 1. Opening MATLAB  Students, please open MATLAB now.  CLICK on the shortcut icon → Alternatively, select… start/All.
Chapter 3 MATLAB Fundamentals Introduction to MATLAB Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
1 Week 1: Variables, assignment, expressions READING: 1.2 – 1.4.
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
ENG College of Engineering Engineering Education Innovation Center 1 More Script Files in MATLAB Script File I/O : Chapter 4 1.Global Variables.
Getting Started with MATLAB (part 3) 1. Algebra, 2. Trig 3. The keyword ans 4. Clean up and suppress output: finalizing the software’s presentation 1.
Lecture 5 1.What is a variable 2.What types of information are stored in a variable 3.Getting user input from the keyboard 1.
C++ Programming Lecture 9 Functions – Part I By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz SUNY-New Paltz “Lecture 2”
1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
EGR 115 Introduction to Computing for Engineers Introduction to MATLAB Friday 29 August 2014 EGR 115 Introduction to Computing for Engineers.
A simple classification problem Extract attributes Pattern Pattern recognition decision x C1 C2.
Interduction to MATLAB Manal Alotaibi Mathematics department College of science King saud university.
ENG 1181 First-Year Engineering Program College of Engineering Engineering Education Innovation Center First-Year Engineering Program MAT - Introduction.
Basics of Matlab UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
ENG 1181 College of Engineering Engineering Education Innovation Center 1 Script File Input – Output : Chapter 4 PLEASE HAVE STUDENTS START MATLAB NOW.
Today we will learn MATLAB Click Start  All programm  Class Software  Matlab This command window will be seen with a prompt sign >> Any command can.
Matlab for Engineers Matlab Environment Chapter 2.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
Basic operations in Matlab EE 201.  Achieve Comprehension LOL of Matlab basic operations. Class Learning Objectives 2.
Introduction to MATLAB
ECE 1304 Introduction to Electrical and Computer Engineering
Arithmetic Operations
ECE 1304 Introduction to Electrical and Computer Engineering
BIL 104E Introduction to Scientific and Engineering Computing
Introduction to Programming
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
INTRODUCTION TO MATLAB
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
Experiment No. (1) - an introduction to MATLAB
MATLAB Introduction MATLAB can be thought of as a powerful graphing calculator but with a lot more buttons! It is also a programming language, commands.
Introduction to MATLAB
Basics of Matlab UC Berkeley Fall 2004, E Copyright 2005, Andy Packard
MatLab Program Used to Calculate Interactive
Introduction to Matlab
Electrical and Computer Engineering Department SUNY – New Paltz
Presentation transcript:

ENG 1181 College of Engineering Engineering Education Innovation Center MATLAB is a powerful program for numerical computations, plotting and programming.  Use it as a calculator.  Define variables and use them in calculations.  Use built-in functions.  Plot graphs.  Write and run computer programs.  Perform symbolic mathematics. Introduction to MATLAB Starting with MATLAB / Chapter 1

ENG 1181 STUDENTS PLEASE START MATLAB NOW Click on the shortcut icon  or select start / All programs / MATLAB The following prompt should appear in the command window after a fairly long initialization process: >>

ENG 1181 MATLAB Display (Default Setting) Command Window (where commands are entered) Command History (what has been typed) Workspace (variable values) Command prompt Current Directory (lists files, etc.) Ribbon (useful operations)

ENG 1181 MATLAB’s Working Directory When you first start MATLAB it is a good practice to change the working directory to your Z: drive or USB device. You can use the Browse Icon

ENG 1181 ORDER OF PRECEDENCE ( VERY Important to understand!) Higher-precedence operations are executed before lower-precedence operations (like Excel or programmable calculators). If two operations have the same precedence, then the expression is executed from left to right. PRECEDENCEOPERATION FirstParentheses (innermost pair first) SecondExponentiation. ThirdMultiplication and division FourthAddition and subtraction

ENG 1181 Topic : Precedence of Operations >> / 2 ans = 11 >> (7+8)/2 ans = Question : Find the average of 2 numbers : 7 and 8 Not what we wanted !!!

ENG 1181 Topic : Precedence of Operations >> 27 ^ 1/ ^ 0.2 ans = 11 Press up arrow key and add parenthesis around the 1/3 Question : Add the cube root of 27 to the 5 th root of 32 Not what we wanted !!! >> 27 ^ (1/3) + 32 ^ 0.2 ans = 5

ENG 1181 Topic : Important points about variable definition >> x = 5 x = 5 >> x = x + 5 x = 10 This statement does not make any mathematical sense but in programming language it changes the value of ‘x’ to a new value

ENG 1181 Topic : Calculations with variables >> a + my_var ans = 20 We can use the variables defined previously to do calculations >> a * my_var ^ 2 ans = 1152 Remember a=8 and my_var =12

ENG 1181 RULES ABOUT VARIABLES NAMES  Can be up to 63 characters long.  Must begin with a letter.  Can contain letters, digits, and the underscore character (no spaces).  MATLAB is case sensitive; it distinguishes between UPPERCASE and lowercase letters.  Avoid naming variables names that are used by MATLAB for example, exp, sin, cos, sqrt, length, mean, max, min etc.

ENG 1181 EXAMPLES OF VARIABLES NAMES Correct  My_name  MyName Incorrect  1Name ( starts with numeral)  My Name ( no spaces allowed)  My-Name ( no special characters allowed)

ENG 1181 MATLAB BUILT-IN MATH FUNCTIONS: Examples exp(x)exponential (e x ) log(x) natural logarithm (log base “e”, written ln in math expressions) log10(x) base 10 logarithm (log in math expressions) sqrt(x) square root abs(x) absolute value NOTE: For trigonometric functions, x is in radians sin(x), cos(x), asin(x), acos(x), tan(x), cot(x) For each trig function there is an equivalent, e.g. sind(x) where x is in degrees

ENG 1181 Topic : Built in Math functions >> sin(pi/2) ans = 1 If you want to calculate sin(π / 2) >> exp(2) If you want to calculate e 2 ans = π is already defined inside MATLAB as ‘pi’ >> e ^ 2 ??? Undefined function or variable 'e'.

ENG 1181 Topic : Built in Math functions >> x = pi/4 x = If you want to calculate sin2x where x = π /4 >> sin(2*x) ans = 1

ENG 1181 Topic : Built in Math functions >> x = 30 x = 30 Given a function : (cos2xsin 2 x + tan(x/2)) / e 3x Find the value for x = 30 degrees >> x = x* pi / 180 x = Convert x in radians >> (cos(2*x)* sin(x)^2 + tan(x/2)) / exp(3*x) ans =

ENG 1181 SAVING A SCRIPT FILE  Once the script file is completed, it must be saved. In our class use Save As to your Z:\ or USB drive. This should be the same as the working directory you specified when you started MATLAB.  The name of the script file follows some rules Valid File Names Invalid File Names Prob1a.m Prob 1a.m (Note a blank) Prob_1a.m 1aProb.m (Cannot start with numeric) Prob-1a.m (No special characters)

ENG 1181 Some useful programming commands % It clears the command window >> clc To clear the command window To clear ALL variables previously defined from the memory leave the command window untouched! First we define x=5 using the following command >> x = 5 x = 5 >> clear >> x ??? Undefined function or variable ‘x’ % It clears only the variables

ENG 1181 Disp function Brutus Buckeye To send a text message to the command window You can also display contents of variables with this command >> x = 5 x = 5 >> disp(x) x = 5 >> disp(‘Brutus Buckeye’) Note: single quotes Note: NO single quotes

ENG 1181 Suppressing command window output >> x = 5 x = 5 >> x=6; The value of x is changed but not displayed >> x x = 6

ENG 1181 Example with Script file Pythagoras Theorem: Height Base Hypotenuse Hypotenuse 2 = Height 2 + Base 2 Create a script file and name it Pyth.m Clear the command window Clear all variables from memory Display your name and seat number Declare height of triangle as 3 units Declare base of triangle as 4 units Find the hypotenuse of the triangle

ENG 1181 Print of the Script File Print of the Output

ENG 1181 ASSIGNMENT : MAT01 – Introduction HW

ENG 1181 Homework Example clc disp ('Student, Joe') disp ('EG1181, Seat 99') disp ('MAT - Introduction') disp ('Problem 4') prob4a = cos(5*pi … … Script File Student, Joe EG1181, Seat 99 MAT - Introduction Problem 4 prob4a = … Command Window Submit a printout of both the Script File and the Command Window

ENG 1181 Important examples  Arithmetic Operations with scalars : 5+3, 5*3, 5^3  Precedence of operations : 7+8/2, (7+8)/2, 27^ 1/3 + 32^ 0.2, 27^ (1/3) + 32^ 0.2  Variable assignment : a=8, b=12  Calculations with variables : a+b, a*b  Important commands : clc, clear  Use of ; after a statement to suppress the output  Use of disp : disp(‘Brutus Buckeye’)  Mathematical functions : sin(pi/2), exp(2)  Calculate the value of (cos2xsinx + tan(x/2)) / exp(3x) for x = 30 degrees