Introduction to Mathematical Programming

Similar documents
System Design S.CS301

MatLab Just a beginning

Numerical Methods in Engineering Sciences

MATLAB is a multi-paradigm numerical computing environment fourth-generation programming language. A proprietary programming language developed by

Engineering Innovation Center MATLAB Basics

MATLAB. Devon Cormack and James Staley

Introduction to Scilab Use Scilab, not Matlab

Numerical Methods Lecture 1

Introduction to Matlab

Introduction to MATLAB. Recommended bibliography. Need more help? Session 1. Getting started.

Introduction to MATLAB programming: Fundamentals

Introduction to MATLAB Programming

7 Control Structures, Logical Statements

EE 301 Signals & Systems I MATLAB Tutorial with Questions

Fall 2014 MAT 375 Numerical Methods. Introduction to Programming using MATLAB

Introduction to MATLAB

Introduction to Octave/Matlab. Deployment of Telecommunication Infrastructures

MATH 3511 Basics of MATLAB

Lab 0a: Introduction to MATLAB

EE 350. Continuous-Time Linear Systems. Recitation 1. 1

How to Write Fast Numerical Code Spring 2012 Lecture 9. Instructor: Markus Püschel TAs: Georg Ofenbeck & Daniele Spampinato

Chapter 2. MathScript

Complex Dynamic Systems

Computational Photonics, Summer Term 2014, Abbe School of Photonics, FSU Jena, Prof. Thomas Pertsch

SMS 3515: Scientific Computing Lecture 1: Introduction to Matlab 2014

Introduction to MATLAB

Objectives of this lesson

CITS2401 Computer Analysis & Visualisation

MATLAB Basics EE107: COMMUNICATION SYSTEMS HUSSAIN ELKOTBY

MATLAB INTRODUCTION. Risk analysis lab Ceffer Attila. PhD student BUTE Department Of Networked Systems and Services

ME 121 MATLAB Lesson 01 Introduction to MATLAB

Introduction to Scientific Computing with Matlab

Introduction to Matlab

MATH 5520 Basics of MATLAB

A Brief Introduction to MATLAB Evans Library Research Support Workshops

STAT/MATH 395 A - PROBABILITY II UW Winter Quarter Matlab Tutorial

Introduction to Scientific Computing with Matlab

Getting Started with MATLAB

What is MATLAB? What is MATLAB? Programming Environment MATLAB PROGRAMMING. Stands for MATrix LABoratory. A programming environment

Matlab Programming MET 164 1/24

function [s p] = sumprod (f, g)

Ordinary Differential Equation Solver Language (ODESL) Reference Manual

MATLAB GUIDE UMD PHYS401 SPRING 2011

Fall 2017: Numerical Methods I Assignment 1 (due Sep. 21, 2017)

Introduction to Matlab

The Mathematics of Big Data

How to Write Fast Numerical Code

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

How to Write Fast Numerical Code Spring 2011 Lecture 7. Instructor: Markus Püschel TA: Georg Ofenbeck

Dr Richard Greenaway

ENGR 253 LAB #1 - MATLAB Introduction

Free Software Alternatives to Commercial Math Software

Introduction to MATLAB. Computational Probability and Statistics CIS 2033 Section 003

Constraint-based Metabolic Reconstructions & Analysis H. Scott Hinton. Matlab Tutorial. Lesson: Matlab Tutorial

Introduction to Matlab. By: Hossein Hamooni Fall 2014

Programming (ERIM) Lecture 1: Introduction to programming paradigms and typing systems. Tommi Tervonen

Starting Matlab. MATLAB Laboratory 09/09/10 Lecture. Command Window. Drives/Directories. Go to.

A Tour of Matlab for Math 496, Section 6

MATLAB Basics. Configure a MATLAB Package 6/7/2017. Stanley Liang, PhD York University. Get a MATLAB Student License on Matworks

Introduction to Scripting Languages. October 2017

Introduction to MATLAB LAB 1

Lecture 2 Matlab Environment

MATLAB 1. Jeff Freymueller September 24, 2009

(Creating Arrays & Matrices) Applied Linear Algebra in Geoscience Using MATLAB

George Mason University ECE 201: Introduction to Signal Analysis Spring 2017

Introduction to System Simulation Techniques and Applications

Chapter 4: Programming with MATLAB

APPM 2460: Week Three For, While and If s

MATH 2221A Mathematics Laboratory II

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

An Introduction to Matlab for DSP

Introduction to Scilab

Worksheet 1. Hello Matlab

MATLAB Tutorial EE351M DSP. Created: Thursday Jan 25, 2007 Rayyan Jaber. Modified by: Kitaek Bae. Outline

INTENDED LEARNING OUTCOMES

LECTURE 1. What Is Matlab? Matlab Windows. Help

Introduction to Engineering gii

Introduction to Matlab

Computational Methods of Scientific Programming

HW0 v3. October 2, CSE 252A Computer Vision I Fall Assignment 0

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB

PROGRAMMING IN VISUAL BASIC WITH MICROSOFT VISUAL STUDIO Course: 10550A; Duration: 5 Days; Instructor-led

Lecture (01) Introduction

Applications of MATLAB/Simulink for Process Dynamics and Control

MATLAB Lesson I. Chiara Lelli. October 2, Politecnico di Milano

Introduction to Matrix Operations in Matlab

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB

PRACTICAL file. Department: Computer Science and Engineering. Simulation and Modeling Lab. Subject Code: BTCS 607. Semester:

Eric W. Hansen. The basic data type is a matrix This is the basic paradigm for computation with MATLAB, and the key to its power. Here s an example:

Python for Earth Scientists

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB

Digital Image Analysis and Processing CPE

MATLAB Introduction. Ron Ilizarov Application Engineer

A quick Matlab tutorial

MATLAB MATLAB mat lab funtool

Introduction to MATLAB

Variable Definition and Statement Suppression You can create your own variables, and assign them values using = >> a = a = 3.

MATLAB/Octave Tutorial

1. Register an account on: using your Oxford address

An Introduction to MATLAB

Transcription:

Introduction to Mathematical Programming Ming Zhong Lecture 3 September 5, 2018 Ming Zhong (JHU) AMS Fall 2018 1 / 14

Programming with MATLAB Table of Contents 1 Programming with MATLAB 2 Logic, Loops and Iterations Ming Zhong (JHU) AMS Fall 2018 2 / 14

Programming with MATLAB What Is MATLAB MATrix LABoratory is: A multi-paradigm numerical computing environment and proprietary programming language developed by MathWorks. has interface to work with C, C++, C#, Java, Fortran, and Python. has support for symbolic computing via MuPAD symbolic engine. adds multi-domain simulation, and model-based design for dynamic and embedded systems via Simulink. Strong support on matrix manipulations, plotting, user interfaces. First developed by Cleve Moler in late 1970 s (wrapper of LINPACK and EISPACK); rewritten by Jack Little, Steve Banger and Moler in C in 1984, put into commercial use, the new libraries were called JACKPAC. In, 2000, a new set of libraries called LAPACK was put into MATLAB. Popular in the teaching of Linear Algebra, Numerical Analysis, and image processing. Ming Zhong (JHU) AMS Fall 2018 3 / 14

Programming with MATLAB MATLAB Files File Extensions:.m: code (function, script, or class);.mat :data;.mex*: executable files;.p: content-obscured file;.mlx: live script;.fig: figures;.mlapp: apps;.mlappinstall: package App Installer;.mlpkginstall: support package installer;.mltx,.mltbx: package custom toolbox;.prj: project files;.rpt: report setup file; Ming Zhong (JHU) AMS Fall 2018 4 / 14

Programming with MATLAB How to Install MATLAB Do the following: log onto my.jhu.edu; go to Technology, then mysoftware, click on https://itservices. johnshopkins.edu/serviceportal?id=evg_software. under Search the Software Catalog, click on Matlab for Students, find the activation key, and follows the steps there. Ming Zhong (JHU) AMS Fall 2018 5 / 14

Programming with MATLAB Variables in MATLAB Variables in MATLAB: no need to declare them, just assign values, variables can be re-assigned to become different types; >> x = [1 3 2] creates the row vector, x = ( 1 3 2 ). 1 >> x = [1; 3; 2] creates the column vector, x = 3. 2 >> x = 0 : 1 : 10 creates x = ( 0 1 2 10 ) (syntax: >> x = a : h : b or >> x = a : b). >> x = linspace(0, 10, 11) does the same. 1 3 2 >> A = [1 3 2; 5 6 7; 8 3 1] creates A = 5 6 7. 8 3 1 Ming Zhong (JHU) AMS Fall 2018 6 / 14

Programming with MATLAB Indexing of Matrices in MATLAB >> x = A(2, 3) to access the a 2,3 of A; >> x = A(2, :) to access the second row of A. >> x = A(:, 3) to access the third column of A. ( ) 6 >> x = A(2 : 3, 2) to have x =. 3 >> x = A(3, 2 : end) to have x = ( 3 1 ). ( ) 3 2 >> C = A(1 : end 1, 2 : 3) to have C =. 6 7 ( ) 3 2 >> D = [A(1, 2 : 3); A(1 : 2, 3). ] to have D =. 2 7 3 + 2i x = 1, y = x., so y = ( 3 + 2i 1 8 ) ; y = x, so 8 y = ( 3 2i 1 8 ). Ming Zhong (JHU) AMS Fall 2018 7 / 14

Programming with MATLAB Logical Indexing Let x = [ 1 2 3 5 2], y1 = (x > 0); y2 = (x > 0). x; y3 = (x > 0) 3; y 1 = ( 0 1 1 1 0 ) ; y 2 = ( 0 2 3 5 0 ) ; y 3 = ( 0 3 3 3 0 ) ; y4 = zeros(1, 5), y4(x > 0) = x(x > 0). y 4 = ( 0 2 3 5 0 ). Ming Zhong (JHU) AMS Fall 2018 8 / 14

Logic, Loops and Iterations Table of Contents 1 Programming with MATLAB 2 Logic, Loops and Iterations Ming Zhong (JHU) AMS Fall 2018 9 / 14

Logic, Loops and Iterations Logic Expressions Logic MATLAB expression equal to == not equal to = greater than > great than or equal to >= less than < less than or equal to <= AND & OR Ming Zhong (JHU) AMS Fall 2018 10 / 14

Logic, Loops and Iterations Loops The if -statement: if (logical statement) elseif (logical statement) else (logical statement) end Ming Zhong (JHU) AMS Fall 2018 11 / 14

Logic, Loops and Iterations Loops The switch -statement: switch (variable) case value1 case value2 otherwise end Ming Zhong (JHU) AMS Fall 2018 12 / 14

Logic, Loops and Iterations The for -statement: for (assign counters) end The while -statement: while (logical expression) end Ming Zhong (JHU) AMS Fall 2018 13 / 14

Logic, Loops and Iterations Finding a root of f (x) = exp(x) tan(x) Let us look at the graphs: Ming Zhong (JHU) AMS Fall 2018 14 / 14