Introduction to MATLAB Northeastern University: College of Computer and Information Science Co-op Preparation University (CPU) 10/22/2003.

Slides:



Advertisements
Similar presentations
Matlab Intro Simple introduction to some basic Matlab syntax. Declaration of a variable [ ] Matrices or vectors Some special (useful) syntax. Control statements.
Advertisements

Introduction to M ATLAB Programming Ian Brooks Institute for Climate & Atmospheric Science School of Earth & Environment
Introduction to Matlab
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 10.
Introduction to Matlab Workshop Matthew Johnson, Economics October 17, /13/20151.
M AT L AB Programming: scripts & functions. Scripts It is possible to achieve a lot simply by executing one command at a time on the command line (even.
MATLAB – What is it? Computing environment / programming language Tool for manipulating matrices Many applications, you just need to get some numbers in.
Introduction to MATLAB Northeastern University: College of Computer and Information Science Co-op Preparation University (CPU) 10/20/2003.
Engineering Computation using MATLAB
COSC 120 Computer Programming
Introduction to MATLAB Northeastern University: College of Computer and Information Science Co-op Preparation University (CPU) 10/22/2003.
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 Northeastern University: College of Computer and Information Science Co-op Preparation University (CPU) 10/29/2003.
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 programming in MATLAB MATLAB can be thought of as an super-powerful graphing calculator Remember the TI-83 from calculus? With many more.
CS102 Introduction to Computer Programming
January 24, 2005 Lecture 3 - By P. Lin 1 CPET 190 Lecture 3 Problem Solving with MATLAB
MATLAB Lecture One Monday 4 July Matlab Melvyn Sim Department of Decision Sciences NUS Business School
Introduction to MATLAB Session 1 Prepared By: Dina El Kholy Ahmed Dalal Statistics Course – Biomedical Department -year 3.
You can make this in matlab!. Matlab Introduction and Matrices.
MATLAB Tutorials Session I Introduction to MATLAB Rajeev Madazhy Dept of Mechanical Engineering LSU.
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.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Programing Concept Ken Youssefi/Ping HsuIntroduction to Engineering – E10 1 ENGR 10 Introduction to Engineering (Part A)
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.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
INTRODUCTION TO MATLAB LAB# 01
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (1): Introduction.
Matlab Basics Tutorial. Vectors Let's start off by creating something simple, like a vector. Enter each element of the vector (separated by a space) between.
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.
10/24/20151 Chapter 2 Review: MATLAB Environment Introduction to MATLAB 7 Engineering 161.
Matlab The language of Technical computing Mr. D. Suresh Assistant Professor, Dept. of CSE, PSNA CET, Dindigul.
Chapter 3 MATLAB Fundamentals Introduction to MATLAB Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Introduction to Matlab. Outline:  What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display.
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 Array Accessing and Strings in MATLAB Topics Covered: 1.Array addressing. 2.
Chapter 6 Review: User Defined Functions Introduction to MATLAB 7 Engineering 161.
Working with Arrays in MATLAB
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
Introduction to MATLAB Northeastern University: College of Computer and Information Science Co-op Preparation University (CPU) 10/20/2003.
INTRODUCTION TO MATLAB DAVID COOPER SUMMER Course Layout SundayMondayTuesdayWednesdayThursdayFridaySaturday 67 Intro 89 Scripts 1011 Work
Digital Image Processing Introduction to MATLAB. Background on MATLAB (Definition) MATLAB is a high-performance language for technical computing. The.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
1 Lecture 4 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS ( NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS (PRACTICAL PART) Tutorial 2 : Matlab - Getting Started.
SCRIPTS AND FUNCTIONS DAVID COOPER SUMMER Extensions MATLAB has two main extension types.m for functions and scripts and.mat for variable save files.
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.
1-2 What is the Matlab environment? How can you create vectors ? What does the colon : operator do? How does the use of the built-in linspace function.
ECE 1304 Introduction to Electrical and Computer Engineering
Release Numbers MATLAB is updated regularly
Introduction to MATLAB
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
Matlab Workshop 9/22/2018.
MATH 493 Introduction to MATLAB
Use of Mathematics using Technology (Maltlab)
Communication and Coding Theory Lab(CS491)
Introduction to MATLAB
Introduction to MATLAB
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
Introduction to MATLAB
Experiment No. (1) - an introduction to MATLAB
Matlab Basics Tutorial
Computer Simulation Lab
Presentation transcript:

Introduction to MATLAB Northeastern University: College of Computer and Information Science Co-op Preparation University (CPU) 10/22/2003

Overview for 10/22/2003 Review of topics covered in last session (10/20/2003) Review of the MATLAB environment (covered in last session) Declaring and manipulating variables Useful functions

Review of 10/20/2003 Contact Information Course Overview MATLAB Overview

Contact Information “Office Hours”: Wednesday after class Some information available: –

Course Overview Course Structure

Week 1: Overview of MATLAB –History of MATLAB –Overview of MATLAB environment –Discussion of MATLAB in co-op Week 2: Basic MATLAB –Simple MATLAB functionality Syntax, Commands –Exercises involving basic MATLAB functionality

Course Structure, con’t: 2 Week 3: Advanced MATLAB Functionality –Beyond MATLAB as a calculator –The MATLAB programming language –Project showcasing MATLABs advanced functionality

Meeting Times and Locations Week 1 –Class 1 Monday, Oct. 20, p.m., 257 CN –Class 2 Wednesday, Oct. 22, p.m., 257 CN –Class 3 Thursday, Oct. 23, p.m., 247 CN

Meeting Times and Locations, con’t: 2 Week 2 –Class 1 Monday, Oct. 27, p.m., 257 CN –Class 2 Wednesday, Oct. 29, p.m., 257 CN –Class 3 Thursday, Oct. 30, p.m., 247 CN

Meeting Times and Locations, con’t: 3 Week 3 –Class 1 Monday, Nov. 3, p.m., 257 CN –Class 2 Wednesday, Nov. 5, p.m., 257 CN –Class 3 Thursday, Nov. 6, p.m., 247 CN

Coursework Collection of exercises: –Will occur during the second week –Will involve MATLABs basic functionality Final project: –Will occur during the final two sessions –Will cover MATLABs basic and advanced functionality

History of MATLAB Ancestral software to MATLAB –Fortran subroutines for solving linear (LINPACK) and eigenvalue (EISPACK) problems –Developed primarily by Cleve Moler in the 1970’s

History of MATLAB, con’t: 2 Later, when teaching courses in mathematics, Moler wanted his students to be able to use LINPACK and EISPACK without requiring knowledge of Fortran MATLAB developed as an interactive system to access LINPACK and EISPACK

History of MATLAB, con’t: 3 MATLAB gained popularity primarily through word of mouth because it was not officially distributed In the 1980’s, MATLAB was rewritten in C with more functionality (such as plotting routines)

History of MATLAB, con’t: 4 The Mathworks, Inc. was created in 1984 The Mathworks is now responsible for development, sale, and support for MATLAB The Mathworks is located in Natick, MA The Mathworks is an employer that hires co-ops through our co-op program

MATLAB GUI Launch Pad / Toolbox Workspace Current Directory Command History Command Window

Launch Pad / Toolbox Will not be covered Launch Pad allows you to start help/demos Toolbox is for use with specialized packages (Signal Processing)

Workspace Allows access to data Area of memory managed through the Command Window Shows Name, Size (in elements), Number of Bytes and Type of Variable

Current Directory MATLAB, like Windows or UNIX, has a current directory MATLAB functions can be called from any directory Your programs (to be discussed later) are only available if the current directory is the one that they exist in

Command History Allows access to the commands used during this session, and possibly previous sessions Clicking and dragging to the Command window allows you to re-execute previous commands

Command Window Probably the most important part of the GUI Allows you to input the commands that will create variables, modify variables and even (later) execute scripts and functions you program yourself.

Simple Commands who whos save clear load

who who lists the variables currently in the workspace. As we learn more about the data structures available in MATLAB, we will see more uses of “who”

whos whos is similar to who, but also gives size and storage information s = whos(...) returns a structure with these fields name variable name size variable size bytes number of bytes allocated for the array class class of variable and assigns it to the variable s. (We will discuss structures more).

Save save – saves workspace variables on disk save filename stores all workspace variables in the current directory in filename.mat save filename var1 var2... saves only the specified workspace variables in filename.mat. Use the * wildcard to save only those variables that match the specified pattern.

Clear clear removes items from workspace, freeing up system memory Examples of syntax: –clear –clear name –clear name1 name2 name3...

clc Not quite clear clc clears only the command window, and has no effect on variables in the workspace.

Load load - loads workspace variables from disk Examples of Syntax: –load –load filename –load filename X Y Z

Declaring a variable in MATLAB Not necessary to specify a type. (Such as int or float) Several kinds of variables: –Vector –Matrix –Structure –Cell array

Declaring a variable, con’t: 2 For an integer or floating point number: simply set a variable name equal to some character Ex. A = 5; Or A = 5

Sidenote 1 The presence or lack of a semi-colon after a MATLAB command does not generate an error of any kind The presence of a semi-colon tells MATLAB to suppress the screen output of the command

Sidenote 1, con’t: 2 The lack of a semi-colon will make MATLAB output the result of the command you entered One of these options is not necessarily better than the other

Declaring a variable, con’t: 3 You may now use the simple integer or float that you used like a normal number (though internally it is treated like a 1 by 1 matrix) Possible operations: –+, -, / –Many functions (round(), ceil(), floor())

Declaring a variable, con’t: 4 You may also make a vector rather simply The syntax is to set a variable name equal to some numbers, which are surrounded by brackets and separated by either spaces or commas Ex. A = [ ]; Or A = [1,2,3,4,5];

Declaring a variable, con’t: 5 You may also declare a variable in a general fashion much more quickly Ex. A = 1:1:10 The first 1 would indicate the number to begin counting at The second 1 would be the increase each time And the count would end at 10

Declaring a variable, con’t: 6 Matrices are the primary variable type for MATLAB Matrices are declared similar to the declaration of a vector Begin with a variable name, and set it equal to a set of numbers, surrounded by brackets. Each number should be seperated by a comma or semi-colon

Declaring a variable, con’t: 7 The semi-colons in a matrix declaration indicate where the row would end Ex. A = [ 1,2;3,4] would create a matrix that looks like [ ]

Declaring a variable, con’t: 7 Matrices may be used as normal variables now. Multiplying is already defined for matrices, and additional code does not need to be written.

Declaring a variable, con’t: 8 The final type of variable we will discuss today will be a struct. The command struct is used to create a structure Syntax: –s = struct('field1',{},'field2',{},...) –s = struct('field1',values1,'field2',values2,...)

Declaring a variable, con’t 9 A simple declaration of a structure is as follows: Student.name = “Joe”; Student.age = 23; Student.major = “Computer Science”;

Declaring a variable, con’t: 10 Arrays of structures are possible. Taking the previous example, if one were to write: Student(2).name = “Bill” …etc Then the array would be created for you.

Declaring a variable, con’t: 11 Structures can group information, but methods are not written for them.

End Another satisfied MATLAB user!