Introduction to Engineering MATLAB – 2 Introduction to MATLAB - 2 Agenda Defining Variables MATLAB Windows.

Slides:



Advertisements
Similar presentations
Introduction to Programming using Matlab Session 2 P DuffourJan 2008.
Advertisements

Lecture 14 User-defined functions Function: concept, syntax, and examples © 2007 Daniel Valentine. All rights reserved. Published by Elsevier.
Lecture 5.
Welcome to EGR 106 Foundations of Engineering II Course information Today’s specific topics: – Computation and algorithms – M ATLAB Basics Demonstrations.
MATLAB ME1107 Y Yan Reference: MATLAB for Engineers by Holly Moore (Pearson Prentice Hall)
Introduction to MATLAB 3 November Instructor: Andy Newman Office Hours: Stop by room 306 (main building) whenever
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
ES 100: Introduction to Engineering Use of the Computer 1.Log in using your Novell password. If you do not know your password, immediately (now!) see Al.
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.
Programming For Nuclear Engineers Lecture 12 MATLAB (3) 1.
Lecture 1: Introduction Lecture series based on the text: Essential MATLAB for Engineers and Scientists By Hahn & Valentine
MATLAB INTRO CONTROL LAB1  The Environment  The command prompt Getting Help : e.g help sin, lookfor cos Variables Vectors, Matrices, and Linear Algebra.
BRIAN D. HAHN AND DANIEL T. VALENTINE THIRD EDITION Essential MATLAB® for Engineers and Scientists.
THE MATLAB ENVIRONMENT VARIABLES BASIC COMMANDS HELP HP 100 – MATLAB Wednesday, 8/27/2014
Objectives Understand what MATLAB is and why it is widely used in engineering and science Start the MATLAB program and solve simple problems in the command.
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.
ENG 1181 College of Engineering Engineering Education Innovation Center MATLAB is a powerful program for numerical computations, plotting and programming.
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.
Introduction to Engineering MATLAB – 6 Script Files - 1 Agenda Script files.
Copyright © The McGraw-Hill Companies, Inc. Introduction to MATLAB for Engineers, Third Edition William J. Palm III Chapter 1 An Overview of MATLAB.
What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation tools. Others include Maple Mathematica MathCad.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
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.
ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Module 4 Matlab ME 6104 – Fundamentals of Computer-Aided Design.
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 &
Getting Started with MATLAB (part2) 1. Basic Data manipulation 2. Basic Data Understanding 1. The Binary System 2. The ASCII Table 3. Creating Good Variables.
Engineering Analysis – Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
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.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
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.
Introduction to Matlab Electromagnetic Theory LAB by Engr. Mian Shahzad Iqbal.
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.
Part:2.  Keywords are words with special meaning in JavaScript  Keyword var ◦ Used to declare the names of variables ◦ A variable is a location in the.
Introduction to Engineering MATLAB – 4 Arrays Agenda Creating arrays of numbers  Vectors: 1-D Arrays  Arrays: 2-D Arrays Array Addressing Strings & String.
Introduction to Programming Python Lab 3: Arithmetic 22 January PythonLab3 lecture slides.ppt Ping Brennan
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.
Copyright © The McGraw-Hill Companies, Inc. This work is only for non-profit use by instructors in courses for which this textbook has been adopted.
Introduction to MATLAB
ECE 1304 Introduction to Electrical and Computer Engineering
CS005 Introduction to Programming
Introduction to MATLAB for Engineers, Third Edition
Basic operations in Matlab
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
Matlab review Matlab is a numerical analysis system
MATH 493 Introduction to MATLAB
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
Simulation And Modelling
Experiment No. (1) - an introduction to MATLAB
Using Script Files and Managing Data
CS 111 Introduction to Computing in Engineering and Science
Introduction to MATLAB
Basics of Matlab UC Berkeley Fall 2004, E Copyright 2005, Andy Packard
Presentation transcript:

Introduction to Engineering MATLAB – 2 Introduction to MATLAB - 2 Agenda Defining Variables MATLAB Windows

THE ASSIGNMENT OPERATOR In MATLAB, the = sign is called the ASSIGNMENT OPERATOR. The ASSIGNMENT OPERATOR assigns a value to a variable. For example, if you type: >> x = 3 x = 3 MATLAB assigns a new value to x, which is the old value 3 plus 5. (In mathematics this expression has no meaning since it implies: 0 = 5.) MATLAB assigns the value of 3 to x. If then you type: >> x = x + 5 x = 8

THE ASSIGNMENT OPERATOR Variable = A value, or a computable value The left hand side can only be one variable. The right hand side can be a specific value, or a computable expression (an expression that includes values and/or previously defined variables). For example, the statement: x + 4 = 30 is not valid. MATLAB does not solve for x, but the statement: x = 30 – 4 is valid (the number 26 is assigned to x.)

DEFINING VARIABLES A variable is defined by typing a variable name followed by the assignment operator (equal sign) and then a value, or a mathematical expression. Once a variable is defined, the computer remembers and stores its value. The variable can then be used in further calculations. >> a=8 a = 8 >> B=12 B = 12 >> a+B ans = 20 >> a/B ans = >> B/a ans = >> B^a ans = Type and press Enter Computer response Type and press Enter Computer response

Variables can also be used to define new variables Once in existence, variables can be used in functions >> d=a*B d = 96 >> sqrt(d) ans = A previously defined variable can be redefined and reassigned a new value.

RULES ABOUT VARIABLES NAMES  Variable names can be up to 21 characters long.  Variable name can contain letters, numbers, and the underscore character.  Variable name must begin with a letter.  MATLAB is case sensitive; it distinguishes between uppercase and lowercase letters. For example, A and a are not the same variable.

PREDEFINED VARIABLES MATLAB has several variables that are predefined. These variables can be redefined to have any other value. It is probably better not to use the predefined variables as variable names. Some of the predefined variables are: pi (  ), eps (the smallest number) inf (infinity) i (square root of –1) j (square root of –1) ans (the value of the most recent calculation) >> pi ans = Typing these variables gives: >> eps ans = e-016 >> inf ans = Inf >> i ans = i >> sin(pi/4) ans =

AVOID USING NAMES OF FUNCTIONS FOR VARIABLES. This means that variables should not be called sin, cos, exp, tan, sqrt, ……., etc. OR: max, min, sum, det, …., etc. Once a function name is used to define a variable, the function can not be used.

SOME USEFUL COMMANDS When these commands are typed in the Command Window they either provide information, or perform a task. ; When a semicolon is typed at the end of a line, the computer does not displays the output. >> abc=37 abc = 37 >> def=23; >> clc Clears the command window. clear Removes all variables from memory. clear x y z Clears only variables x, y and z. who Lists the variables currently in memory. clf Clears the Figure Window. %typing % at the beginning of a line designates the line as a comment, which is not executed.

ASSIGNMENT 2: 1.Calculate: 2.Calculate: 3.Problem 4 page 58 in the textbook. 4.Problem 5 page 58 in the textbook. 5.Problem 6 page 59 in the textbook. Do the problems above in the command window. Start each problem in a new (clear) window. The first two lines in each problem should be: % (type: First Name, Last Name) % Assignment 1, Problem Number: (type: the problem number) Submit the printout of the command window.

Windows Today, we worked in the MATLAB command window. In future weeks, we will use other MATLAB windows  Figure window  Editor window

Command window: Main window that opens when MATLAB is started. It has the command prompt ’ » ‘. All commands can be typed in this window. Used for running programs written by user.  Figure window: Contains graphs created by graphics commands. This window opens automatically.  Editor window: Used for writing and editing programs. This window is opened from the File menu in the command window.  Help window: Contains help information. This window is opened from the Help menu in any of the previous windows. MATLAB windows:

Command Window Command prompt (The command window opens when MATLAB is started)

Figure Window (The Figure Window opens automatically by the plot command)

(The Editor Window is opened from the file menu in the command window) Editor Window