MATLAB Technical Computing Environment. MATLAB Matlab is an interactive computing environment that enables numerical computation and data visualization.

Slides:



Advertisements
Similar presentations
Welcome to EGR 106 Foundations of Engineering II Course information Today’s specific topics: – Computation and algorithms – M ATLAB Basics Demonstrations.
Advertisements

CSE123 Introduction to Computing
Division Example 2x - 3y + 4z = 10 x + 6y - 3z = 4 -5x + y + 2z = 3 A*X = B where A = B = >> X = A\B X =
JavaScript, Third Edition
Introduction to MATLAB
Basic Input/Output and Variables Ethan Cerami New York
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.
MATLAB INTRO CONTROL LAB1  The Environment  The command prompt Getting Help : e.g help sin, lookfor cos Variables Vectors, Matrices, and Linear Algebra.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
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.
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.
Input, Output, and Processing
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.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Chapter 3 MATLAB Fundamentals Introduction to MATLAB Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
EGR 115 Introduction to Computing for Engineers Introduction to MATLAB Friday 29 August 2014 EGR 115 Introduction to Computing for Engineers.
ENG 1181 First-Year Engineering Program College of Engineering Engineering Education Innovation Center First-Year Engineering Program MAT - Introduction.
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.
CSE123 Introduction to Computing Lecture 2 Introduction to MATLAB.
Matlab for Engineers Matlab Environment Chapter 2.
Interduction to MATLAB (part 2) Manal Alotaibi Mathematics department College of science King saud university.
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
MATLAB The name of MATLAB stands for matrix laboratory. Starting a MATLAB Session -On Microsoft® Windows® platforms, start the MATLAB program by double-clicking.
ECE 1304 Introduction to Electrical and Computer Engineering
Arithmetic Operations
Topics Designing a Program Input, Processing, and Output
Chapter 6 JavaScript: Introduction to Scripting
Release Numbers MATLAB is updated regularly
Basics (Variables, Assignments, I/O)
BASIC ELEMENTS OF A COMPUTER PROGRAM
Chapter 2 - Introduction to C Programming
Introduction to MATLAB for Engineers, Third Edition
Introduction to Scripting
Chapter 2 - Introduction to C Programming
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
Variables and Arithmetic Operations
Basics (Variables, Assignments, I/O)
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
INPUT & OUTPUT scanf & printf.
MATLAB (Lecture 2) BY:MAHA ALMOUSA.
WEB PROGRAMMING JavaScript.
Use of Mathematics using Technology (Maltlab)
Chapter 2 - Introduction to C Programming
Numbers.
T. Jumana Abu Shmais – AOU - Riyadh
Chapter 2 - Introduction to C Programming
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
Introduction to Java Applications
Topics Designing a Program Input, Processing, and Output
Simulation And Modelling
Experiment No. (1) - an introduction to MATLAB
Topics Designing a Program Input, Processing, and Output
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.
Chapter 2 - Introduction to C Programming
CS 111 Introduction to Computing in Engineering and Science
Introduction To MATLAB
Introduction to C Programming
MATLAB (Lecture 2) BY:MAHA ALMOUSA.
MatLab Program Used to Calculate Interactive
Presentation transcript:

MATLAB Technical Computing Environment

MATLAB Matlab is an interactive computing environment that enables numerical computation and data visualization. Matrix Operations Differential Equations Fourier Transforms Statistics and much more..

Running MATLAB MATLAB Programming Environment M-File (Script) Editor (We will cover this in the following weeks)

MATLAB Interface Command Window Workspace/ Current Directory Command History

Getting Help help, by itself, lists all help topics help topic provides help for the speci.ed topic help command provides help for the specified command help help provides information on use of the help command helpwin – On-line help, separate window for navigation. helpdesk – Comprehensive hypertext documentation and troubleshooting demo – Run demonstrations intro – Interactive introduction to Matlab

Arithmetic Operations OperatorsAlgebraicMATLABExample Additiona+b 5+3 Substractiona-b 5-3 Multiplicationaxba*b5*3 Right Divisiona/b 49/7 Left Divisionb/aa\b7/56 Exponentiationabab a^b5^2

Precedence of Operations Since several operations can be combined in one expression, there are rules about the order in which these operations are performed: Parentheses, innermost first Exponentiation (^), left to right Multiplication (*) and division (/ or \) with equal precedence, left to right Addition (+) and subtraction (−) with equal precedence, left to right

Variables and Assignment Statements Variable names can be assigned to represent numerical values in Matlab. The rules for these variable names are: Must start with a letter May consist only of the letters a-z, digits 0-9, and the underscore character (_) 31 characters max Is case sensitive: items, Items, itEms, and ITEMS are all different variable names Variable assignment in MATLAB variable = numberunitcost = 0.30 numberofitems = 5 variable = expression totalcost = unitcost * numberofitems

Special Variables ans: the answer of previous calculation pi: ratio of circle circumference to its diameter, π = Scientific notation 12x e-27

Commands involving variables: who: lists the names of defined variables whos: lists the names and sizes of defined variables clear: clears all variables, resets default values of special variables clear var: clears variable var clc: clears the command window, but does not affect variables. clf: clears the current figure and thus clears the graph window. more on: enables paging of the output in the command window. more off: disables paging of the output in the command window. When more is enabled and output is being paged, advance to the next line of output by pressing Enter ; get the next page of output by pressing the spacebar. Press q to exit out of displaying the current item.

Command Reuse and Editing Commands can be reused and editted using the following operations: Press the up arrow cursor key (↑) to scrolls backward through previous commands. Press Enter to execute the selected command. The down arrow cursor key (↓) scrolls forward through commands The left (←) and right arrow (→) cursor keys move within a command at the Matlab prompt, allowing the command to be edited. The mouse can also be used to reposition the command cursor, by positioning the mouse cursor and pressing the left mouse button. Once a scrolled or edited command is acceptable, pressing Enter with the cursor anywhere in the command tells Matlab to process it. Escape key Esc erases the current command at the prompt.

Punctuation and Comments Semicolon (;) at the end of a command suppresses the display of the result Commas and semicolons can be used to place multiple commands on one line, with commas producing display of results, semicolons supressing Percent sign (%) begins a comment, with all text up to the next line ignored by Matlab Three periods (...) at the end of a command indicates that the command continues on the next line. A continuation cannot be given in the middle of a variable name.

Basic Mathematical Functions abs(x):Absolute value |x| sign(x):Sign, returns -1 if x 0 exp(x):Exponential e x log(x):Natural logarithm ln x log10(x):Common (base 10) logarithm log10 x sqrt(x):Square root √x rem(x,y):Remainder of x/y. For example, rem(100,21) is 16. (enter help elfun for a more complete list)

Display Options Matlab Example Comments format short decimal digits format long decimal digits format short e e decimal digits plus exponent format long e e decimal digits plus exponent format bank decimal digits Note: The display formats do not change the internal representation of a number; only the display changes.

Displaying Values and Text There are three ways to display values and text in Matlab, to be described in this section: By entering the variable name at the Matlab prompt, without a semicolon. By use of the command disp. By use of the command fprintf.

disp() There are two general forms of the command disp that are useful in displaying results and annotating them with units or other information: disp(variable): Displays value of variable without displaying the variable name. disp(string): Displays string by stripping of the single quotes and echoing the characters between the quotes. String: A group of keyboard characters enclosed in single quote marks (’). The quote marks indicate that the enclosed characters are to represent ASCII text. >> temp = 78; >> disp(temp); disp(’degrees Celcius’) 78 degrees Celcius

fprintf() fprintf(’format string’, list of variables) w.d%fDisplay as fixed point or decimal notation (defaults to short), with a width of w characters (including the decimal point and possible minus sign, with d decimal places. Spaces are filled in from the left if necessary. Set d to 0 if you don’t want any decimal places, for example %5.0f. Include leading zeros if you want leading zeroes in the display, for example %06.0f. w.d%e Display using scientific notation (defaults to short e), with a width of w characters (including the decimal point, a possible minus sign, and five for the exponent), with d digits in the mantissa after the decimal point. The mantissa is always adjusted to be less than 1. \nNew line (skip to beginning of next line)

fprintf() The w.d width specifiers are optional. If they are left out, default values are used. Examples: >> fprintf(’The temperature is %f degrees F \n’, temp) The temperature is degrees F >> fprintf(’The temperature is %4.1f degrees F \n’, temp) The temperature is 78.0 degrees F