Chapter 1 Introduction to MATLAB

Size: px
Start display at page:

Download "Chapter 1 Introduction to MATLAB"

Transcription

1 EGR115 Introduction to Computing for Engineers Introduction to MATLAB from: S.J. Chapman, MATLAB Programming for Engineers, 5 th Ed Cengage Learning Topics Introduction: Computing for Engineers 1.1 The Advantages of MATLAB 1.2 Disadvantages of MATLAB 1.4 Using MATLAB as a Calculator

2 Slide 1 of 14 Introduction: Computing for Engineers Father of Computing: Charles Babbage ( ) Charles Babbage ( ), an English mathematician, is best remembered for originating the first concept of a programmable computation machinery * (original concept of today s computer). *Note on the Application of Machinery to the Computation of Astronomical and Mathematical Tables, Royal Astronomical Society (1822). The Babbage Analytical Engine ( ) The mill executed the operations on values retrieved from the store (CPU). The store used punched cards adapted from the Jacquard to specify input (MEMORY). The machine eats its own tail the output redirects to the input for further instructions. ALU (Arithmetic Logic Unit) Computer s Central Processing Unit (CPU) that performs operations on binary numbers (bitwise math). Multiple ALUs can be found in a single CPU. In some processors, the ALU is divided into AU (Arithmetic Unit) and LU (Logical Unit). Are today s most advanced computers POWERFUL ENOUGH to do anything? NASA Columbia ( ERAU Prescott: Advanced Computing & Simulations Laboratory (ACSL)

3 1.1/1.2 The Advantages/Disadvantages of MATLAB Slide 2 of 14 The Purpose of EGR115 (Introduction to Computing for Engineers) It is NOT the purpose of this course to make you learn how to use MATLAB. MATLAB is simply the choice of computer language (or software) for you to learn how to understand and apply computing (design/develop/debug/deploy computer programs) for an effective engineering problem solutions. The MATLAB (MATrix LABoratory) A special-purpose computer program originally developed to perform engineering and scientific calculations. As the name implies, the software was originally developed for matrix calculations (Algebra/Calculus applications). Today, MATLAB has been grown to be one of the most used engineering/scientific software tools. The origins of MATLAB: Advantages & Disadvantages of MATLAB MATLAB is an INTERPRETER (no need to compile: means, ease of use), platform independent, predefined functions, device-independent plotting, and capable for developing a Graphical User Interface (GUI). MATLAB is an INTERPRETER (no need to compile: means, slower than compiled language) and the software is prohibitively expensive for personal (and academic research) use. Any solution(s)?: MATLAB Just-In-Time (JIT) Compiler / GNU Octave

4 Slide 3 of 14 The MATLAB Desktop (this is where you begin...) Current Folder Browser shows a list of the files in the current folder Workspace Browser shows variables defined in workspace MATLAB Editor Details Window displays properties of file selected above MATLAB Command Window NOTE: the textbook is written for MATLAB 2014b The fundamental unit of data in MATLAB is the ARRAY: an array is a collection of data values organized into rows & columns (MATRIX) and given a single name. As an interpreter, you can just quickly write up your computer code and run it: no need to compile your code (means: decode language instructions into command so that you can execute your developed code in a computer). The MATLAB Desktop The MATLAB desktop is the collection of 4 windows: COMMAND WINDOW, COMMAND HISTORY, CURRENT FOLDER, and WORKSPACE. When you create (new) or open (import and load an existing file) a MATLAB script (knows as M-FILE ), a MATLAB EDITOR opens. As you simply type, save, and run MATLAB script, you can execute your program (getting a result). MATLAB is an interpreter: no need to compile your program! Just run the program: if the program is good, you ll get a result. If the program is bad, you ll get an error. The MATLAB Command Window A user can enter interactive MATLAB commands at the command prompt (>>). The MATLAB accepts commands, interpret/execute it, and then output result(s). For example, >> diameter = 10 diameter = 10 Command Window >> area = (pi/4)*(diameter^2) area =

5 Slide 4 of 14 MATLAB Toolstrip (selection of tools & commands) Dock/Undock Each Individual Window The MATLAB windows can be either docked (to form a desktop) or undocked (to be used as an individual window). Just click the top-right-corner of each window The PANELS icon (in Quick Access Toolbar) also controls the MATLAB Windows The MATLAB Toolstrip The MATLAB toolstrip conveniently provides you quick access tabs to some key control functions, based on the categorized groups: HOME, PLOTS, APPS, EDITOR, PUBLISH, and VIEW. The most commonly used tab will (most likely) be the EDITOR tab: this is going to be used for developing your own MATLAB script (m-file) by typing the code, open/save the m-file, test run/time/debug the code. The MATLAB Command History The Command History Window appears when you click the PANELS icon (in Quick Access Toolbar: above) or just simply hit up arrow key ( ) while you type in the Command Window. Commands remain in the list until they are deleted (it is kept even after you close the program).

6 Slide 5 of 14 Script (the M-File : the program code you ll develop/run) a b c d The MATLAB Script File ( M-File ) Instead of typing commands directly in the Command Window, a series of commands can be placed into a file, and the entire file can be executed by typing its name in the Command Window. Open a new script and save as calc_area.m Type the same commands into the MATLAB Editor (save the file after you re done typing) Type calc_area into MATLAB Command Window Command Window >> calc_area diameter = 10 area = The MATLAB script file ( m-file ) can be created (new) by choosing: (a) new script under HOME tab (then, the MATLAB Editor will automatically open) or (if a script is already open in MATLAB Editor): (b) new => script under EDITOR tab (then, a new m-file will be added into the MATLAB Editor). The MATLAB Editor can be used in docked mode (c) or undocked (individual window) mode (d). The MATLAB m-file is a simple ASCII text file (.txt): thus, one can even create a MATLAB m-file by using any text editor (i.e., notepad) and can import into MATLAB (file extension must be changed from.txt into.m ). ASCII = American Standard Code for Information Interchange (ASCII code is a numerical representation of a character set: computers can only understand binary numbers...)

7 Slide 6 of 14 MATLAB Workspace (this is where your variables are...) The MATLAB Workspace Using the MATLAB Editor, create a simple script: Editor % calc_area2.m % Simple MATLAB M-File Demo radius = 2.5; area = pi * radius^2; string = [ The area of the circle is num2str(area)]; disp(string); Then, run the script in Command Window: Command Window >> calc_area2 The area of the circle is Executing the script will create variables in Workspace, namely: area, radius, and string. A list of variables (ARRAYS) in MATLAB Workspace can be generated with the whos command: Command Window >> whos Name Size Bytes Class Attributes Area 1x1 8 double Radius 1x1 8 double String 1x32 64 char

8 Slide 7 of 14 EXAMPLE 1-1 Calculate and plot sin(x) versus x for the range of 0 x 6 by using MATLAB script (M-file). % example_1_1_sin_x.m % % This is the very first MATLAB M-File % Calculation & Plot the function sin(x) % Range 0 <= x <=6 (increment of 0.1) % x = 0:0.1:6 y = sin(x) plot(x,y) The MATLAB Figure Window When a plotting command is executed, MATLAB automatically opens a new window (the FIGURE WINDOW) and completes the plot within the figure window. The strong plotting capability is one of the unique advantages of MATLAB, making this software extremely effective for engineering and scientific problem solutions. (Network\prfsvs01.erau.edu\Courses (T):\EGR115\Hayashibara\EXAMPLES\) example_1_1_sin_x.m

9 Slide 8 of 14 EXAMPLE 1-2 Calculate and plot cos(x) versus x for the range of 0 x 6 by using MATLAB script (M-file). Then, can we plot BOTH sin(x) (from example 1-1) and cos(x) on the same figure window? % example_1_2_cos_x.m % % This is the 2nd MATLAB M-File % Plot the function sin(x) & cos(x) % Range 0 <= x <=6 (increment of 0.1) % Then plot BOTH sin(x) & cos(x) % clc clear all close all x = 0:0.1:6 y1 = sin(x) y2 = cos(x) plot(x,y1,x,y2) (Network\prfsvs01.erau.edu\Courses (T):\EGR115\Hayashibara\EXAMPLES\) example_1_2_cos_x.m

10 Slide 9 of 14 Do-It-Yourself (DIY) EXERCISE 1-1 Develop a MATLAB script (M-File) to plot the function: y x 2e 0.2x for the range of 0 x 10. % exercise_1_1_exp_x.m %... Use the MATLAB Editor to create a new empty M-File, type statements, save the file with the name exercise_1_1_exp_x.m. Then, execute the program by typing the M-File name (exercise_1_1_exp_x) in the Command Window. What results can you get? exercise_1_1_exp_x.m

11 Slide 10 of 14 Do-It-Yourself (DIY) EXERCISE 1-2 Develop a MATLAB script (M-File) to plot the function: 2log10x y x for the range of 0 x 10. Then, plot BOTH exp(x) (from exercise 1-1) and log(x) on the same figure window. % exercise_1_2_log_x.m % clc clear all close all... exercise_1_2_log_x.m

12 Slide 11 of 14 MATLAB Current Folder Browser and Documentation The MATLAB Workspace Browser / Array Editor The MATLAB workspace variables (arrays with m n size) can be seen in Workspace Browser. After executing example_1_2_cos_x.m, you ll see: If you double click each variable, you can view/edit actual numerical values allocated within the array (stored in the memory of a computer you are running). The MATLAB Current Folder Browser and Documentation You can set the working directory of your MATLAB session by choosing the current folder. A comprehensive MATLAB documentation can be accessed easily at search box.

13 Slide 12 of 14 Do-It-Yourself (DIY) EXERCISE 1-3 Answer the followings (use your own words to explain): (a) What is the purpose of the MATLAB Command Window? The Edit Window? The Figure Window? (b) List the different ways that you get help in MATLAB. (c) What is a workspace? How can you determine what is stored in a MATLAB workplace? (d) How can you clear the contents of a workspace? How can you clear the current command window? How can you close figure window(s)? The MATLAB Set Path As you start working MATLAB project, you ll find it would be useful to set a particular working directory for quick access. You can do that by HOME => Set Path. (a) The MATLAB command window takes interactive user command inputs. A user can enter a command at the command prompt (>>). Then the MATLAB interprets/executes the command and outputs result(s). Instead of typing commands manually, a user can develop a script file (the MATLAB M-File) and execute the script by type the name of the script in the command window. The MATLAB command window is the core component of the MATLAB environment. The MATLAB Editor allows the user develop (new) and edit (existing) MATLAB scripts (M-Files). The Editor also can let the user test run/time/debug/deploy the script. The MATLAB figure window allows the plot (2-D/3-D) within the window, upon execution of plot commands. (b) Use MATLAB help browser (built-in MATLAB documentation) At the command window, type help command/function name At the command window, type lookfor command/function name (c) The MATLAB workspace is a part of computer memory used to store variables defined by a user. A list of variables in the current workspace can be generated by whos command. You can view/edit actual values stored within each variable by using MATLAB workspace browser and array editor. (d) clear = clear variables in workspace clear all = clear all local/global user-defined variables and all functions from the symbol table clc = clear contents of current command window close all = close all currently open figure window

14 Slide 13 of Using MATLAB as a Calculator EXAMPLE 1-3 (a) Suppose that x = 3 and y = 4. Use MATLAB to evaluate the following 2 2 expression: x y x y 2 (b) Calculate the volume of a cylinder of radius r (0.1) and length l (0.5) by using MATLAB command window. Note that: Area is A = r 2 and Volume is V = Al Using the MATLAB Editor, develop simple scripts (m-files): Editor % example_1_3a.m x = 3 y = 4 ((x^2)*(y^2))/(x-y)^2 % example_1_3b.m r = 0.1; l = 0.5; area = pi*r^2 volume = area*l Editor Then, run the script in Command Window: >> example_1_3a.m x = 3 y = 4 ans = 144 Command Window >> example_1_3b.m area = volume = Command Window Getting Help in MATLAB 3 Ways to get help in MATLAB: (i) Help browser (built-in MATLAB documentation): The help browser (in Quick Access Toolbar) opens MATLAB documentation (with search options) In command window, type either (ii) help or (iii) lookfor (followed by a specific command/function name) A Few Important MATLAB Commands clc = clear contents of current command window clf = clear contents of current figure window clear = clear variables in workspace clear all = clear all local/global user-defined variables and all functions from the symbol table close all = close all currently open figure window abort (or CTRL+c ) = terminate the current execution of commands diary = record everything done during a MATLAB session (diary filename)

15 Slide 14 of Using MATLAB as a Calculator exercise_1_4.m Do-It-Yourself (DIY) EXERCISE 1-4 (a) Suppose that x = 2 and y = 1, evaluate the following expressions using MATLAB: 4 3 2x 4 2 y 3 (b) Suppose that u = 2 and v = 3, evaluate the following expressions using MATLAB: u 2v v u v v u 3 v v (c) The distance traveled by a ball falling in the air is given by the equation: x x0 vot 0.5at 2 Use MATLAB (save your program code in M-File script) to calculate the position of the ball x (m) at: Time t = 5 (s) x 0 = 10 (m) v o = 15 (m/s) a = 9.81 (m/s 2 ) Editor Command Window % exercise_1_4.m >> exercise_1_4 % (a) x = 2; ans_a1 = 2 y = -1; ans_a1 = (2*x^3)^(1/4) ans_a2 = i ans_a2 = (2*y^3)^(1/4) % (b) ans_b1 = u = 2; v = 3; ans_b2 = ans_b1 = (4*u)/(3*v) ans_b2 = (2*v^(-2))/((u+v)^2) ans_b3 = ans_b3 = (v^3)/(v^3-u^3) ans_b4 = (4/3)*pi*v^2 ans_b4 = % (c) t = 5; ans_c_x = x0 = 10; v0 = 15; a = -9.81; ans_c_x = x0+v0*t+0.5*a*t^2

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

An Introduction to MATLAB See Chapter 1 of Gilat

An Introduction to MATLAB See Chapter 1 of Gilat 1 An Introduction to MATLAB See Chapter 1 of Gilat Kipp Martin University of Chicago Booth School of Business January 25, 2012 Outline The MATLAB IDE MATLAB is an acronym for Matrix Laboratory. It was

More information

2.2 Creating & Initializing Variables in MATLAB

2.2 Creating & Initializing Variables in MATLAB 2.2 Creating & Initializing Variables in MATLAB Slide 5 of 27 Do-It-Yourself (DIY) EXERCISE 2-1 Answer the followings: (a) What is the difference between an array, a matrix, and a vector? (b) Let: c =

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

Chapter 2 MATLAB Basics

Chapter 2 MATLAB Basics EGR115 Introduction to Computing for Engineers MATLAB Basics from: S.J. Chapman, MATLAB Programming for Engineers, 5 th Ed. 2016 Cengage Learning Topics 2.1 Variables & Arrays 2.2 Creating & Initializing

More information

Introduction to MATLAB

Introduction to MATLAB Chapter 1 Introduction to MATLAB MATLAB Matrix Laoratory A special-purpose program optimized to perform engineering and scientific calculations Chapter M1: Introduction to MATLAB 1 MATLAB Integrated development

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

MATLAB Introduction to MATLAB Programming

MATLAB Introduction to MATLAB Programming MATLAB Introduction to MATLAB Programming MATLAB Scripts So far we have typed all the commands in the Command Window which were executed when we hit Enter. Although every MATLAB command can be executed

More information

MATLAB The first steps. Edited by Péter Vass

MATLAB The first steps. Edited by Péter Vass MATLAB The first steps Edited by Péter Vass MATLAB The name MATLAB is derived from the expression MATrix LABoratory. It is used for the identification of a software and a programming language. As a software,

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

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

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

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

Short Version of Matlab Manual

Short Version of Matlab Manual Short Version of Matlab Manual This is an extract from the manual which was used in MA10126 in first year. Its purpose is to refamiliarise you with the matlab programming concepts. 1 Starting MATLAB 1.1.1.

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB Introduction: MATLAB is a powerful high level scripting language that is optimized for mathematical analysis, simulation, and visualization. You can interactively solve problems

More information

Desktop Command window

Desktop Command window Chapter 1 Matlab Overview EGR1302 Desktop Command window Current Directory window Tb Tabs to toggle between Current Directory & Workspace Windows Command History window 1 Desktop Default appearance Command

More information

Matlab = Matrix Laboratory. It is designed to be great at handling matrices.

Matlab = Matrix Laboratory. It is designed to be great at handling matrices. INTRODUCTION: Matlab = Matrix Laboratory. It is designed to be great at handling matrices. Matlab is a high-level language and interactive environment. You write simple ASCII text that is translated into

More information

Introduction to. The Help System. Variable and Memory Management. Matrices Generation. Interactive Calculations. Vectors and Matrices

Introduction to. The Help System. Variable and Memory Management. Matrices Generation. Interactive Calculations. Vectors and Matrices Introduction to Interactive Calculations Matlab is interactive, no need to declare variables >> 2+3*4/2 >> V = 50 >> V + 2 >> V Ans = 52 >> a=5e-3; b=1; a+b Most elementary functions and constants are

More information

A Brief Introduction to MATLAB

A Brief Introduction to MATLAB A Brief Introduction to MATLAB MATLAB (Matrix Laboratory) is an interactive software system for numerical computations and graphics. As the name suggests, MATLAB was first designed for matrix computations:

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

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

Lab 1 Introduction to MATLAB and Scripts

Lab 1 Introduction to MATLAB and Scripts Lab 1 Introduction to MATLAB and Scripts EE 235: Continuous-Time Linear Systems Department of Electrical Engineering University of Washington The development of these labs was originally supported by the

More information

Matlab Programming MET 164 1/24

Matlab Programming MET 164 1/24 Matlab Programming 1/24 2/24 What does MATLAB mean? Contraction of Matrix Laboratory Matrices are rectangular arrays of numerical values 7 3 6 2 1 9 4 4 8 4 1 5 7 2 1 3 What are the fundamental components

More information

ME 1020 Engineering Programming with MATLAB. Chapter 1 In-Class Assignment: 1.1, 1.3, 1.13, Topics Covered:

ME 1020 Engineering Programming with MATLAB. Chapter 1 In-Class Assignment: 1.1, 1.3, 1.13, Topics Covered: ME 1020 Engineering Programming with MATLAB Chapter 1 In-Class Assignment: 1.1, 1.3, 1.13, 1.16 Topics Covered: Use MATLAB as a calculator Save files to folders and open files from folders Create row vector

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

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

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB MATLAB stands for MATrix LABoratory. Originally written by Cleve Moler for college linear algebra courses, MATLAB has evolved into the premier software for linear algebra computations

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

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

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

CE890 / ENE801 Lecture 1 Introduction to MATLAB

CE890 / ENE801 Lecture 1 Introduction to MATLAB CE890 / ENE801 Lecture 1 Introduction to MATLAB CE890: Course Objectives Become familiar with a powerful tool for computations and visualization (MATLAB) Promote problem-solving skills using computers

More information

Chapter 1: An Overview of MATLAB

Chapter 1: An Overview of MATLAB Chapter 1: An Overview of MATLAB MATLAB is: A high-level language and interactive environment for numerical computation, visualization, and programming MATLAB can: Be used as a calculator, easily create

More information

Appendix A. Introduction to MATLAB. A.1 What Is MATLAB?

Appendix A. Introduction to MATLAB. A.1 What Is MATLAB? Appendix A Introduction to MATLAB A.1 What Is MATLAB? MATLAB is a technical computing environment developed by The Math- Works, Inc. for computation and data visualization. It is both an interactive system

More information

MAT 275 Laboratory 1 Introduction to MATLAB

MAT 275 Laboratory 1 Introduction to MATLAB MATLAB sessions: Laboratory 1 1 MAT 275 Laboratory 1 Introduction to MATLAB MATLAB is a computer software commonly used in both education and industry to solve a wide range of problems. This Laboratory

More information

MATLAB. Miran H. S. Mohammed. Lecture 1

MATLAB. Miran H. S. Mohammed. Lecture 1 MATLAB Miran H. S. Mohammed 1 Lecture 1 OUTLINES Introduction Why using MATLAB Installing MATLAB Activate your installation Getting started Some useful command Using MATLAB as a calculator 2 INTRODUCTION

More information

Introduction to MATLAB Programming. Chapter 3. Linguaggio Programmazione Matlab-Simulink (2017/2018)

Introduction to MATLAB Programming. Chapter 3. Linguaggio Programmazione Matlab-Simulink (2017/2018) Introduction to MATLAB Programming Chapter 3 Linguaggio Programmazione Matlab-Simulink (2017/2018) Algorithms An algorithm is the sequence of steps needed to solve a problem Top-down design approach to

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

Getting started with Matlab: Outline

Getting started with Matlab: Outline Getting started with Matlab: Outline What, where and why of matlab. The matlab desktop and you Entering commands Variables and data types Plotting 101 Saving and loading data A real world example What

More information

INTRODUCTION TO MATLAB

INTRODUCTION TO MATLAB 1 of 18 BEFORE YOU BEGIN PREREQUISITE LABS None EXPECTED KNOWLEDGE Algebra and fundamentals of linear algebra. EQUIPMENT None MATERIALS None OBJECTIVES INTRODUCTION TO MATLAB After completing this lab

More information

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER BENC 2113 DENC ECADD 2532 ECADD LAB SESSION 6/7 LAB

More information

Introduction to MATLAB

Introduction to MATLAB Chapter 1 Introduction to MATLAB 1.1 Software Philosophy Matrix-based numeric computation MATrix LABoratory built-in support for standard matrix and vector operations High-level programming language Programming

More information

Matlab notes Matlab is a matrix-based, high-performance language for technical computing It integrates computation, visualisation and programming usin

Matlab notes Matlab is a matrix-based, high-performance language for technical computing It integrates computation, visualisation and programming usin Matlab notes Matlab is a matrix-based, high-performance language for technical computing It integrates computation, visualisation and programming using familiar mathematical notation The name Matlab stands

More information

A/D Converter. Sampling. Figure 1.1: Block Diagram of a DSP System

A/D Converter. Sampling. Figure 1.1: Block Diagram of a DSP System CHAPTER 1 INTRODUCTION Digital signal processing (DSP) technology has expanded at a rapid rate to include such diverse applications as CDs, DVDs, MP3 players, ipods, digital cameras, digital light processing

More information

ECON 502 INTRODUCTION TO MATLAB Nov 9, 2007 TA: Murat Koyuncu

ECON 502 INTRODUCTION TO MATLAB Nov 9, 2007 TA: Murat Koyuncu ECON 502 INTRODUCTION TO MATLAB Nov 9, 2007 TA: Murat Koyuncu 0. What is MATLAB? 1 MATLAB stands for matrix laboratory and is one of the most popular software for numerical computation. MATLAB s basic

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

Matlab for FMRI Module 1: the basics Instructor: Luis Hernandez-Garcia

Matlab for FMRI Module 1: the basics Instructor: Luis Hernandez-Garcia Matlab for FMRI Module 1: the basics Instructor: Luis Hernandez-Garcia The goal for this tutorial is to make sure that you understand a few key concepts related to programming, and that you know the basics

More information

Lecture 1: What is MATLAB?

Lecture 1: What is MATLAB? Lecture 1: What is MATLAB? Dr. Mohammed Hawa Electrical Engineering Department University of Jordan EE201: Computer Applications. See Textbook Chapter 1. MATLAB MATLAB (MATrix LABoratory) is a numerical

More information

Creates a 1 X 1 matrix (scalar) with a value of 1 in the column 1, row 1 position and prints the matrix aaa in the command window.

Creates a 1 X 1 matrix (scalar) with a value of 1 in the column 1, row 1 position and prints the matrix aaa in the command window. EE 350L: Signals and Transforms Lab Spring 2007 Lab #1 - Introduction to MATLAB Lab Handout Matlab Software: Matlab will be the analytical tool used in the signals lab. The laboratory has network licenses

More information

What is MATLAB? It is a high-level programming language. for numerical computations for symbolic computations for scientific visualizations

What is MATLAB? It is a high-level programming language. for numerical computations for symbolic computations for scientific visualizations What is MATLAB? It stands for MATrix LABoratory It is developed by The Mathworks, Inc (http://www.mathworks.com) It is an interactive, integrated, environment for numerical computations for symbolic computations

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

MATLAB = MATrix LABoratory. Interactive system. Basic data element is an array that does not require dimensioning.

MATLAB = MATrix LABoratory. Interactive system. Basic data element is an array that does not require dimensioning. Introduction MATLAB = MATrix LABoratory Interactive system. Basic data element is an array that does not require dimensioning. Efficient computation of matrix and vector formulations (in terms of writing

More information

Introduction to MATLAB

Introduction to MATLAB Quick Start Tutorial Introduction to MATLAB Hans-Petter Halvorsen, M.Sc. What is MATLAB? MATLAB is a tool for technical computing, computation and visualization in an integrated environment. MATLAB is

More information

Introduction to Scientific Computing with Matlab

Introduction to Scientific Computing with Matlab UNIVERSITY OF WATERLOO Introduction to Scientific Computing with Matlab SAW Training Course R. William Lewis Computing Consultant Client Services Information Systems & Technology 2007 Table of Contents

More information

MATLAB Demo. Preliminaries and Getting Started with Matlab

MATLAB Demo. Preliminaries and Getting Started with Matlab Math 250C Sakai submission Matlab Demo 1 Created by G. M. Wilson, revised 12/23/2015 Revised 09/05/2016 Revised 01/07/2017 MATLAB Demo In this lab, we will learn how to use the basic features of Matlab

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

CSE/NEUBEH 528 Homework 0: Introduction to Matlab

CSE/NEUBEH 528 Homework 0: Introduction to Matlab CSE/NEUBEH 528 Homework 0: Introduction to Matlab (Practice only: Do not turn in) Okay, let s begin! Open Matlab by double-clicking the Matlab icon (on MS Windows systems) or typing matlab at the prompt

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

Introduction to Matlab. Summer School CEA-EDF-INRIA 2011 of Numerical Analysis

Introduction to Matlab. Summer School CEA-EDF-INRIA 2011 of Numerical Analysis Introduction to Matlab 1 Outline What is Matlab? Matlab desktop & interface Scalar variables Vectors and matrices Exercise 1 Booleans Control structures File organization User defined functions Exercise

More information

Chapter 4 Branching Statements & Program Design

Chapter 4 Branching Statements & Program Design EGR115 Introduction to Computing for Engineers Branching Statements & Program Design from: S.J. Chapman, MATLAB Programming for Engineers, 5 th Ed. 2016 Cengage Learning Topics Introduction: Program Design

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB This note will introduce you to MATLAB for the purposes of this course. Most of the emphasis is on how to set up MATLAB on your computer. The purposes of this supplement are two.

More information

Programming 1. Script files. help cd Example:

Programming 1. Script files. help cd Example: Programming Until now we worked with Matlab interactively, executing simple statements line by line, often reentering the same sequences of commands. Alternatively, we can store the Matlab input commands

More information

An Introduction to Numerical Methods

An Introduction to Numerical Methods An Introduction to Numerical Methods Using MATLAB Khyruddin Akbar Ansari, Ph.D., P.E. Bonni Dichone, Ph.D. SDC P U B L I C AT I O N S Better Textbooks. Lower Prices. www.sdcpublications.com Powered by

More information

Lab 1 Intro to MATLAB and FreeMat

Lab 1 Intro to MATLAB and FreeMat Lab 1 Intro to MATLAB and FreeMat Objectives concepts 1. Variables, vectors, and arrays 2. Plotting data 3. Script files skills 1. Use MATLAB to solve homework problems 2. Plot lab data and mathematical

More information

MATLAB Tutorial III Variables, Files, Advanced Plotting

MATLAB Tutorial III Variables, Files, Advanced Plotting MATLAB Tutorial III Variables, Files, Advanced Plotting A. Dealing with Variables (Arrays and Matrices) Here's a short tutorial on working with variables, taken from the book, Getting Started in Matlab.

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

Part I. Introduction to Linux

Part I. Introduction to Linux Part I Introduction to Linux 7 Chapter 1 Linux operating system Goal-of-the-Day Familiarisation with basic Linux commands and creation of data plots. 1.1 What is Linux? All astronomical data processing

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab By:Mohammad Sadeghi *Dr. Sajid Gul Khawaja Slides has been used partially to prepare this presentation Outline: What is Matlab? Matlab Screen Basic functions Variables, matrix, indexing

More information

Matlab Tutorial. The value assigned to a variable can be checked by simply typing in the variable name:

Matlab Tutorial. The value assigned to a variable can be checked by simply typing in the variable name: 1 Matlab Tutorial 1- What is Matlab? Matlab is a powerful tool for almost any kind of mathematical application. It enables one to develop programs with a high degree of functionality. The user can write

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

ENGR 105: Introduction to Scientific Computing. Dr. Graham. E. Wabiszewski

ENGR 105: Introduction to Scientific Computing. Dr. Graham. E. Wabiszewski ENGR 105: Introduction to Scientific Computing Machine Model, Matlab Interface, Built-in Functions, and Arrays Dr. Graham. E. Wabiszewski ENGR 105 Lecture 02 Answers to questions from last lecture Office

More information

LAB 2: Linear Equations and Matrix Algebra. Preliminaries

LAB 2: Linear Equations and Matrix Algebra. Preliminaries Math 250C, Section C2 Hard copy submission Matlab # 2 1 Revised 07/13/2016 LAB 2: Linear Equations and Matrix Algebra In this lab you will use Matlab to study the following topics: Solving a system of

More information

INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX

INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX 1) Objective The objective of this lab is to review how to access Matlab, Simulink, and the Communications Toolbox, and to become familiar

More information

CSCI 6906: Fundamentals of Computational Neuroimaging. Thomas P. Trappenberg Dalhousie University

CSCI 6906: Fundamentals of Computational Neuroimaging. Thomas P. Trappenberg Dalhousie University CSCI 6906: Fundamentals of Computational Neuroimaging Thomas P. Trappenberg Dalhousie University 1 Programming with Matlab This chapter is a brief introduction to programming with the Matlab programming

More information

Laboratory 1 Octave Tutorial

Laboratory 1 Octave Tutorial Signals, Spectra and Signal Processing Laboratory 1 Octave Tutorial 1.1 Introduction The purpose of this lab 1 is to become familiar with the GNU Octave 2 software environment. 1.2 Octave Review All laboratory

More information

Chapter 11 Input/Output (I/O) Functions

Chapter 11 Input/Output (I/O) Functions EGR115 Introduction to Computing for Engineers Input/Output (I/O) Functions from: S.J. Chapman, MATLAB Programming for Engineers, 5 th Ed. 2016 Cengage Learning Topics Introduction: MATLAB I/O 11.1 The

More information

AMS 27L LAB #2 Winter 2009

AMS 27L LAB #2 Winter 2009 AMS 27L LAB #2 Winter 2009 Plots and Matrix Algebra in MATLAB Objectives: 1. To practice basic display methods 2. To learn how to program loops 3. To learn how to write m-files 1 Vectors Matlab handles

More information

ME 121 MATLAB Lesson 01 Introduction to MATLAB

ME 121 MATLAB Lesson 01 Introduction to MATLAB 1 ME 121 MATLAB Lesson 01 Introduction to MATLAB Learning Objectives Be able run MATLAB in the MCECS computer labs Be able to perform simple interactive calculations Be able to open and view an m-file

More information

MatLab Just a beginning

MatLab Just a beginning MatLab Just a beginning P.Kanungo Dept. of E & TC, C.V. Raman College of Engineering, Bhubaneswar Introduction MATLAB is a high-performance language for technical computing. MATLAB is an acronym for MATrix

More information

MATLAB Part 1. Introduction

MATLAB Part 1. Introduction MATLAB Part 1 Introduction MATLAB is problem solving environment which provides engineers and scientists an easy-to-use platform for a wide range of computational problems. In general, it is useful for

More information

Lab. Manual. Practical Special Topics (Matlab Programming) (EngE416) Prepared By Dr. Emad Saeid

Lab. Manual. Practical Special Topics (Matlab Programming) (EngE416) Prepared By Dr. Emad Saeid KINGDOM OF SAUDI ARABIA JAZAN UNIVERSTY College of Engineering Electrical Engineering Department المملكة العربية السعودية وزارة التعليم العالي جامعة جازان كلية الھندسة قسم الھندسة الكھربائية Lab. Manual

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

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

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

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

Why use MATLAB? Mathematcal computations. Used a lot for problem solving. Statistical Analysis (e.g., mean, min) Visualisation (1D-3D)

Why use MATLAB? Mathematcal computations. Used a lot for problem solving. Statistical Analysis (e.g., mean, min) Visualisation (1D-3D) MATLAB(motivation) Why use MATLAB? Mathematcal computations Used a lot for problem solving Statistical Analysis (e.g., mean, min) Visualisation (1D-3D) Signal processing (Fourier transform, etc.) Image

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

Getting Started. Chapter 1. How to Get Matlab. 1.1 Before We Begin Matlab to Accompany Lay s Linear Algebra Text

Getting Started. Chapter 1. How to Get Matlab. 1.1 Before We Begin Matlab to Accompany Lay s Linear Algebra Text Chapter 1 Getting Started How to Get Matlab Matlab physically resides on each of the computers in the Olin Hall labs. See your instructor if you need an account on these machines. If you are going to go

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

Topics. Hardware and Software. Introduction. Main Memory. The CPU 9/21/2014. Introduction to Computers and Programming

Topics. Hardware and Software. Introduction. Main Memory. The CPU 9/21/2014. Introduction to Computers and Programming Topics C H A P T E R 1 Introduction to Computers and Programming Introduction Hardware and Software How Computers Store Data Using Python Introduction Computers can be programmed Designed to do any job

More information

MATLAB BASICS. < Any system: Enter quit at Matlab prompt < PC/Windows: Close command window < To interrupt execution: Enter Ctrl-c.

MATLAB BASICS. < Any system: Enter quit at Matlab prompt < PC/Windows: Close command window < To interrupt execution: Enter Ctrl-c. MATLAB BASICS Starting Matlab < PC: Desktop icon or Start menu item < UNIX: Enter matlab at operating system prompt < Others: Might need to execute from a menu somewhere Entering Matlab commands < Matlab

More information

Chapter 3: Introduction to MATLAB Programming (4 th ed.)

Chapter 3: Introduction to MATLAB Programming (4 th ed.) Chapter 3: Introduction to MATLAB Programming (4 th ed.) Algorithms MATLAB scripts Input / Output o disp versus fprintf Graphs Read and write variables (.mat files) User-defined Functions o Definition

More information

6 Appendix B: Quick Guide to MATLAB R

6 Appendix B: Quick Guide to MATLAB R 6 Appendix B: Quick Guide to MATLAB R 6.1 Introduction In this course we will be using the software package MATLAB R. Version 17.12.0, Release R2011a has been installed in Foster 100, the labs on the third

More information

Lecture 1: Hello, MATLAB!

Lecture 1: Hello, MATLAB! Lecture 1: Hello, MATLAB! Math 98, Spring 2018 Math 98, Spring 2018 Lecture 1: Hello, MATLAB! 1 / 21 Syllabus Instructor: Eric Hallman Class Website: https://math.berkeley.edu/~ehallman/98-fa18/ Login:!cmfmath98

More information

MATLAB Project: Getting Started with MATLAB

MATLAB Project: Getting Started with MATLAB Name Purpose: To learn to create matrices and use various MATLAB commands for reference later MATLAB built-in functions used: [ ] : ; + - * ^, size, help, format, eye, zeros, ones, diag, rand, round, cos,

More information

Unix Computer To open MATLAB on a Unix computer, click on K-Menu >> Caedm Local Apps >> MATLAB.

Unix Computer To open MATLAB on a Unix computer, click on K-Menu >> Caedm Local Apps >> MATLAB. MATLAB Introduction This guide is intended to help you start, set up and understand the formatting of MATLAB before beginning to code. For a detailed guide to programming in MATLAB, read the MATLAB Tutorial

More information

Physics 251 Laboratory Introduction to Spreadsheets

Physics 251 Laboratory Introduction to Spreadsheets Physics 251 Laboratory Introduction to Spreadsheets Pre-Lab: Please do the lab-prep exercises on the web. Introduction Spreadsheets have a wide variety of uses in both the business and academic worlds.

More information

MATLAB Introduction To Engineering for ECE Topics Covered: 1. Creating Script Files (.m files) 2. Using the Real Time Debugger

MATLAB Introduction To Engineering for ECE Topics Covered: 1. Creating Script Files (.m files) 2. Using the Real Time Debugger 25.108 Introduction To Engineering for ECE Topics Covered: 1. Creating Script Files (.m files) 2. Using the Real Time Debugger SCRIPT FILE 77-78 A script file is a sequence of MATLAB commands, called a

More information

MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB

MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB In this laboratory session we will learn how to 1. Create matrices and vectors. 2. Manipulate matrices and create matrices of special types

More information

Introduction to Matlab. By: Dr. Maher O. EL-Ghossain

Introduction to Matlab. By: Dr. Maher O. EL-Ghossain Introduction to Matlab By: Dr. Maher O. EL-Ghossain Outline: q What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display Facilities Flow Control

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