PROGRAMMING WITH MATLAB DR. AHMET AKBULUT

Similar documents
Introduction to Engineering gii

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. 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.

EP375 Computational Physics

Matlab Programming Introduction 1 2

Introduction to MATLAB

Welcome to EGR 106 Foundations of Engineering II

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

This is a basic tutorial for the MATLAB program which is a high-performance language for technical computing for platforms:

Introduction to MATLAB

Digital Image Analysis and Processing CPE

9 Using Equation Networks

Introduction to Programming

Introduction to MATLAB

Dr Richard Greenaway

Finding, Starting and Using Matlab

Basic MATLAB Tutorial

Starting MATLAB To logon onto a Temple workstation at the Tech Center, follow the directions below.

Computer Programming in MATLAB

TECH TIP VISION Calibration and Data Acquisition Software

Numerical Analysis First Term Dr. Selcuk CANKURT

Matlab as a calculator

MATLAB Basics EE107: COMMUNICATION SYSTEMS HUSSAIN ELKOTBY

General Information. There are certain MATLAB features you should be aware of before you begin working with MATLAB.

CSI31 Lecture 5. Topics: 3.1 Numeric Data Types 3.2 Using the Math Library 3.3 Accumulating Results: Factorial

Ordinary Differential Equation Solver Language (ODESL) Reference Manual

General MATLAB Information 1

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

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

MATLAB QUICK START TUTORIAL

EGR 111 Introduction to MATLAB

C++ Programming Lecture 11 Functions Part I

Part V Appendices c Copyright, Todd Young and Martin Mohlenkamp, Department of Mathematics, Ohio University, 2017

Chapter 1 Introduction to MATLAB

LAB 1 General MATLAB Information 1

To start using Matlab, you only need be concerned with the command window for now.

Lab 1 - Worksheet Spring 2013

Programming in Mathematics. Mili I. Shah

Basic stuff -- assignments, arithmetic and functions

Computer Programming ECIV 2303 Chapter 1 Starting with MATLAB Instructor: Dr. Talal Skaik Islamic University of Gaza Faculty of Engineering

AMS 27L LAB #1 Winter 2009

MATLAB The first steps. Edited by Péter Vass

SECTION 1: INTRODUCTION. ENGR 112 Introduction to Engineering Computing

PART 1 PROGRAMMING WITH MATHLAB

Functions and Inverses ID1050 Quantitative & Qualitative Reasoning

Goals for This Lecture:

MATLAB. A Tutorial By. Masood Ejaz

Introduction to Python, Cplex and Gurobi

Introduction to MATLAB

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

Chapter 3. built in functions help feature elementary math functions data analysis functions random number functions computational limits

This appendix provides a quick start introduction to MATLAB. You should be

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

Lecture 1: What is MATLAB?

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

ELEMENTARY MATLAB PROGRAMMING

Introduction to Matlab

Lab of COMP 406. MATLAB: Quick Start. Lab tutor : Gene Yu Zhao Mailbox: or Lab 1: 11th Sep, 2013

Introduction to MATLAB 7 for Engineers

Sketchify Tutorial Properties and Variables. sketchify.sf.net Željko Obrenović

Lesson #3. Variables, Operators, and Expressions. 3. Variables, Operators and Expressions - Copyright Denis Hamelin - Ryerson University

Lecture 1: Hello, MATLAB!

Chapter 2. MATLAB Basis

This page intentionally left blank

A GUIDE FOR USING MATLAB IN COMPUTER SCIENCE AND COMPUTER ENGINEERING TABLE OF CONTENTS

Chapter 2. Outline. Simple C++ Programs

MATLAB NOTES. Matlab designed for numerical computing. Strongly oriented towards use of arrays, one and two dimensional.

ENGR 1181 Autumn 2015 Final Exam Study Guide and Practice Problems

Experiment 1: Introduction to MATLAB I. Introduction. 1.1 Objectives and Expectations: 1.2 What is MATLAB?

MATLAB Programming for Numerical Computation Dr. Niket Kaisare Department Of Chemical Engineering Indian Institute of Technology, Madras

ENGR 1181c Midterm Exam 2: Study Guide and Practice Problems

ENGR 1181 Midterm Exam 2: Study Guide and Practice Problems

McTutorial: A MATLAB Tutorial

6-1 (Function). (Function) !*+!"#!, Function Description Example. natural logarithm of x (base e) rounds x to smallest integer not less than x

Chapter 1: An Overview of MATLAB

1 Introduction to Matlab

Interactive Computing with Matlab. Gerald W. Recktenwald Department of Mechanical Engineering Portland State University

Data Types and Basic Calculation

Introduction to Scientific and Engineering Computing, BIL108E. Karaman

A Guide to Using Some Basic MATLAB Functions

VARIABLES Storing numbers:

Programming in QBasic

Introduction to FORTRAN

Quick MATLAB Syntax Guide

Introduction to Computer Programming in Python Dr. William C. Bulko. Data Types

22-Functions Part 1 text: Chapter ECEGR 101 Engineering Problem Solving with Matlab Professor Henry Louie

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:

Operators Functions Order of Operations Mixed Mode Arithmetic VOID Data. Syntax and type conventions Using the Script window interface

Part #1. A0B17MTB Matlab. Miloslav Čapek Filip Kozák, Viktor Adler, Pavel Valtr

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

Introduction to MatLab. Introduction to MatLab K. Craig 1

Chapter 3 Functions and Files

ME 121 MATLAB Lesson 01 Introduction to MATLAB

Python Programming: An Introduction to Computer Science

Computational Physics

Programming in MATLAB

Engineering Problem Solving with C++, Etter/Ingber

CT 229 Java Syntax Continued

The Number object. to set specific number types (like integer, short, In JavaScript all numbers are 64bit floating point

Transcription:

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 modeling Testing of engineering designs

The Default MATLAB Desktop Layout

ENTERING COMMANDS AND EXPRESSIONS The Command window is where you type MATLAB commands following the prompt: >> The Workspace window shows the variables you created in the current session MATLAB preserves your previously entered commands and expressions Use the up arrow key to scroll back Use the down-arrow key to scroll forward Press the Enter key to execute the command

ARITHMETIC OPERATIONS Operator Operation MATLAB expression + Addition : x + y x + y - Subtraction : x - y x - y / Right division : x / y = x y \ Left division : x \ y = y x x / y x \ y * Multiplication : xy x * y ^ Exponentiation : x y x ^ y

ORDER OF OPERATIONS Precedence Operation First Complete all calculations inside parenthesis or brackets using the precedent rules below (starting with the innermost pair) Second Third Fourth Exponentiation (left to right) Multiplication and division with equal precedence (left to right) Addition and subtraction with equal precedence (left to right)

Some examples: >> 7 + 2*11 ans = 29 >> (7 + 2)*11 ans = 99 >> 3*2^4+5 ans = 53 >> (3*2)^4+5 ans = 1301

WORK SESSION MANAGEMENT Command Description clear removes all variables from memory clear variablea variableb removes the variables variablea and variableb clc clears the command window who lists variables in memory ; semicolon, suppresses screen printing ellipsis, continues a line

BUILT-IN VARIABLES AND CONSTANTS Variable/constant Description pi the number π (3.14159 ) i, j the complex number ( 1) eps The accuracy of floating point precision Inf infinity NaN not a number (an undefined numerical result) ans variable containing the most recent answer

COMMENTS The comment symbol (%) MATLAB ignores everything to the right of this symbol: >> % Here is a comment >> x = 10^-1 % and one more comment x = 0.1000

VARIABLES Create your own variables: >> radius = 2.5 % variable, radius is created, the value 2.5 is stored in the variable radius = 2.5000 >> area = pi * radius^2 area = 19.6350

STRINGS (TEXT VARIABLES) >> day = 'Friday' day = Friday To enter a string put single quotes around it To display variables Type the name of the variable at the command prompt: >> area area = 19.6350 or Use disp function: >> disp('the value of day is:'); disp(day) The value of day is: Friday

NAMING RULES FOR VARIABLES Variable names must begin with a letter Names can include any combinations of letters, numbers, and underscores Avoid the following names: i, j, pi, and all built-in MATLAB function names such as length, size, plot, sin, log, MATLAB is case sensitive. The variable name X is different than the variable name x Do not give a script file the same name as a variable

SOME MATLAB MATH FUNCTIONS Function MATLAB syntax cosine : (cosx) cos(x), x in radians or cosd(x), x in degrees sine : (sinx) sin(x), or sind(x) tangent : (tanx) tan(x), or tand(x) arc cosine : (cos -1 x) acos(x), or acosd(x) arc tangent : (tan -1 x) atan(x), or atand(x) exponential : (e x ) exp(x) square root : ( x) sqrt(x) natural log : lnx, (base e) log(x) logarithm : log 10 x (base 10) log10(x)

COMPLEX NUMBER OPERATIONS A complex number, a = 3 + 5i is entered as follows (an asterisk is not needed between i and 5): >> a = 3 + 5i a = 3.0000 + 5.0000i But, and asterisk is need with a variable (b = 7i*a): >> b = 7i*a b = -35.0000 +21.0000i Try this: >> 5/3i % 5/(3i) ans = 0.0000-1.6667i and: >> 5/3*i % (5/3)i ans = 0.0000 + 1.6667i

MATLAB HELP FUNCTIONS The help command provides information about a function. (help functionname) Type help sqrt at the command window Displays in the Command window a description of the function sqrt. This only works if you know the name of the function lookfor subject: Looks for the string subject of the help text of all m-files found on matlabpath and displays that text doc functionname: Opens the Help Browser to the reference page for the specified function functionname