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

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.
Introduction to Matlab Workshop Matthew Johnson, Economics October 17, /13/20151.
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.
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 Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
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.
Lecture 1: Introduction Lecture series based on the text: Essential MATLAB for Engineers and Scientists By Hahn & Valentine
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
1 Chapter 1 MATLAB Primer This introductory chapter is relatively short and has as its main objective the introduction of MATLAB ® to the reader. This.
Lecture 4 MATLAB Windows Arithmetic Operators Maintenance Functions
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.
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.
Input, Output, and Processing
INTRODUCTION TO MATLAB LAB# 01
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (1): Introduction.
Chapter 1: Getting Started with MATLAB MATLAB for Scientist and Engineers Using Symbolic Toolbox.
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.
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 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.
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
1 DKT 211 Basic Communication Engineering LAB # 1A : (Lecture 1) Introduction to Matlab  Basic Features  Scientific features  Array Operations  Script.
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.
Chapter 6 Review: User Defined Functions Introduction to MATLAB 7 Engineering 161.
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.
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.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
A simple classification problem Extract attributes Pattern Pattern recognition decision x C1 C2.
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.
MA/CS 375 Fall 2002 Lecture 2. Motivation for Suffering All This Math and Stuff Try the Actor demo from
Matlab for Engineers Matlab Environment Chapter 2.
NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS ( NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS (PRACTICAL PART) Tutorial 2 : Matlab - Getting Started.
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.
Some Useful MATLAB Functions
Introduction to MATLAB
ECE 1304 Introduction to Electrical and Computer Engineering
MATLAB® An Introduction.
MATLAB® An Introduction.
Variables, Expressions, and IO
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
Lecture 1: Introduction
Introduction to MATLAB
Digital Image Processing
Matlab.
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
Matlab Basic Dr. Imtiaz Hussain
Experiment No. (1) - an introduction to MATLAB
Using Script Files and Managing Data
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.
Basics of Matlab UC Berkeley Fall 2004, E Copyright 2005, Andy Packard
MatLab Program Used to Calculate Interactive
Introduction to Matlab
Chapter 2 MATLAB Environment
Presentation transcript:

Introduction to Applications & Basic Features

What is MATLAB®? MATLAB® /Simulink® is a powerful software tool for: Performing mathematical computations and signal processing Analyzing and visualizing data (excellent graphics tools) Modeling physical systems and phenomena Testing engineering designs

Industry Applications Aircraft/Defense: control and guidance system design and simulation, communications Robotics: design and control Automotive: cruise control, stability enhancement, fuel injection systems, hybrid power-train, sound suppression … Communications: voice over internet, cell-phone, satellite, antenna design, wireless, error coding … Biotech, Pharmaceutical, Medical: drug discovery and development, imaging procedures, cancer diagnosis …

Industry Applications (cont) Electronics: chip design, acoustics, voice processing and recognition Industrial Automation and Machinery: sensor design, machinery design and control Utilities and Energy: power conversion and control Computers: security systems, printer design Financial: portfolio management and risk, commodity trading, currency markets

MATLAB® Basic Features MATLAB® Desktop: Command Window, Workspace, Command History, Current Folder Using MATLAB® Help Scalar Variables (naming rules, data types, entering and displaying values) Arithmetic Operators and Order of Operations Relational and Logic Operators Functions (sqrt, trig functions, logarithm functions …)

MATLAB Desktop The Command window is where you type MATLAB commands following the prompt: >> The Workspace window shows all the variables you have defined in your current session. Variables can actually be manipulated within the workspace window. The Command History window displays all the MATLAB commands you have used recently – even includes some past sessions. The Current Folder window displays all the files in whatever folder you select to be current.

Naming Rules for Variables 1. Variable names must begin with a letter 2. Names can include any combinations of letters, numbers, and underscores 3. Maximum length for a variable name is 63 characters 4. MATLAB® is case sensitive. The variable name A is different than the variable name a. 5. Avoid the following names: i, j, pi, and all built-in MATLAB® function names such as length, char, size, plot, break, cos, log, … 6. It is good programming practice to name your variables to reflect their function in a program rather than using generic x, y, z variables.

Entering Variables The command >> x = 10.57; creates a variable, x, of type double, assigns a memory location for the variable x, and stores the value in that memory location. If the semicolon is left off, the result (x = 10.57) is displayed in the command window. The commands >> z = 3 – 4j; or >> z = 3 – 4i; or >> z = 3 – i*4; create a complex variable, z of type double. The command >> my_name = Susan; creates a string called, my_name, with the characters Susan

Displaying Variables The command >> x displays the value of variable, x The disp function can also be used to display variables. The commands: >> disp(The value of x is:); disp(x) produces The value of x is: The format function can be used to control how variable values are displayed in MATLAB®. MATLAB® DEMO: Desktop, Help, and Variables

Lab Exercise 1 1.Define the following variables in MATLAB: a = 4 b = 17.2c = 5 – j8 2. Use the disp command to display the following message: The value of b is In the command window, type format long then hit enter. Type a at the command prompt and hit enter and then type b and hit enter. What happens? 4. In the command window, type format short then hit enter to return to the default display. 5. At the command prompt, type: help clc 6. Now type clc at the command prompt and see what happens.

Arithmetic Operators and Order of Operations Addition (+), Subtraction (-), Multiplication (*), Division (/), Power (^) Order of Operations (same rules you should already know from math class and using a calculator) 1. Complete all calculations inside parenthesis or brackets using the precedent rules below 2. Powers (left to right) 3. Multiplication and Division (left to right) 4. Addition and Subtraction (left to right)

Some MATLAB® Functions Note: cos(α) assumes α in radians; whereas, cosd(α) assumes α in degrees. acos(x) returns the angle in radians; whereas, acosd(x) returns the angle in degrees. π radians = 180 degrees

Other Useful Stuff MATLAB® DEMO: Arithmetic Operations and Functions

Lab Exercise 2 Use MATLAB to perform the following set of calculations Make sure you still have a, b, and c from the previous exercise. If not, re-enter the values a= 4, b = 17.2, and c = 5-8j.

Script Files All of the pre-built commands that you use in MATLAB® are script files or functions (plot, mean, std, exp, cosd, …) MATLAB® allows the user to create his/her own customized m-files for specific applications or problems. A script file is simply a collection of executable MATLAB® commands. To create a new script file, click on the New Script icon on the left side of the Home Tab. Function files will be covered in Models II.

Script Files Click on New Script Creates Blank Script File

Script File: Procedure 1.Type a set of executable commands in the editor window. 2.Save the file in an appropriate folder. 3.Set the current directory in MATLAB® to the same place where you saved the Green Run Arrow in the Editor window or simply type the name of the file (without the.m extension) at the command prompt in the MATLAB command window. The file must be in your current directory or it will not run!

Lab Exercise 3: New Script File Right click in the current folder window in MATLAB and create a new folder called Models I. This is where you should save all your files for the fall semester. Double click on the folder to make it your current folder. Clear your MATLAB workspace by typing clear at the command prompt. Click on New Script to open a blank script file. Type the commands on the next slide into the editor window then save the file as CircleScript in your newly created folder.

Lab Exercise 3: Script File Save the file as CircleScript in your newly created folder. Note: Any line that starts with a % is a comment and turns green – it doesnt execute.

Lab Exercise 3: Run the Script File Now run your script file by clicking on the Green Arrow in the m-file editor window. Notice that every single variable defined in the script file (radius, area, diameter, and circum) appears in the Workspace Window. Area and circum are also displayed in the Command Window because of the disp command. Clear the workspace window by typing clear at the command prompt. At the command prompt, type the name of your script file: >> CircleScript. Note, that the results are exactly the same as before.

Script Files A script file is simply a set of executable MATLAB commands saved together in a file. It behaves exactly the same as entering each command sequentially in the command window. Every single variable defined appears in the workspace. Script files can be really useful if you are going to execute a lot of MATLAB commands. For example, suppose you execute 15 commands at the command prompt (>>) and discover an error in the first command that affected the last 14 commands. In the command window, you would have to fix the error in the first command then run the other 14 commands over again. If these commands were in a script file, you could fix the first command and re-run the script file – much faster !!

Lab Exercise 4: Another Script File Create a new script file called SphereScript that will compute and display the surface area and the volume of a sphere. Include comments lines at the beginning (start with a %) that have your name, Lab 1: Intro to MATLAB, and a brief explanation of what your script file does. Demo your script file to your T.A. when you have finished.