Compact Matlab Course

Similar documents
Mechanical Engineering Department Second Year

Control Structures. March 1, Dr. Mihail. (Dr. Mihail) Control March 1, / 28

Matlab Primer. Lecture 02a Optical Sciences 330 Physical Optics II William J. Dallas January 12, 2005

An Introduction to MATLAB

CH6: Programming in MATLAB

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

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

Programming in MATLAB

Chapter 1 Introduction to MATLAB

MATLAB TUTORIAL WORKSHEET

Introduction to MATLAB

MATLAB Operators, control flow and scripting. Edited by Péter Vass

Introduction to MATLAB

Laboratory 1 Octave Tutorial

TUTORIAL 1 Introduction to Matrix Calculation using MATLAB TUTORIAL 1 INTRODUCTION TO MATRIX CALCULATION USING MATLAB

Prof. Manoochehr Shirzaei. RaTlab.asu.edu

MATLAB. Devon Cormack and James Staley

MATLAB Tutorial. Digital Signal Processing. Course Details. Topics. MATLAB Environment. Introduction. Digital Signal Processing (DSP)

MATLAB. MATLAB Review. MATLAB Basics: Variables. MATLAB Basics: Variables. MATLAB Basics: Subarrays. MATLAB Basics: Subarrays

Lecturer: Keyvan Dehmamy

Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition

Introduction and MATLAB Basics

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

Introduction to MATLAB LAB 1

Introduction to MATLAB

Introduction to MATLAB

Flow Control. Statements We Will Use in Flow Control. Statements We Will Use in Flow Control Relational Operators

Matlab Tutorial: Basics

Digital Image Processing

Linear algebra & Numerical Analysis

Introduction to Matlab. By: Hossein Hamooni Fall 2014

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

Relational and Logical Statements

How to Use MATLAB. What is MATLAB. Getting Started. Online Help. General Purpose Commands

Operators. Java operators are classified into three categories:

Outline. User-based knn Algorithm Basics of Matlab Control Structures Scripts and Functions Help

MATLAB: The Basics. Dmitry Adamskiy 9 November 2011

Desktop Command window

Introduction to MATLAB Practical 1

AN INTRODUCTION TO MATLAB

Attia, John Okyere. Control Statements. Electronics and Circuit Analysis using MATLAB. Ed. John Okyere Attia Boca Raton: CRC Press LLC, 1999

2.0 MATLAB Fundamentals

Le L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators

Finding, Starting and Using Matlab

1 Overview of the standard Matlab syntax

Matlab (Matrix laboratory) is an interactive software system for numerical computations and graphics.

Introduction to Matlab

AMS 27L LAB #2 Winter 2009

A QUICK INTRODUCTION TO MATLAB

The Mathematics of Big Data

A Short Tutorial on Matlab ( by T. Co, 2003,2004 )

Chapter 7: Programming in MATLAB

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

CM0340 Tutorial 2: More MATLAB

Mini-Matlab Lesson 5: Functions and Loops

A QUICK INTRODUCTION TO MATLAB. Intro to matlab getting started

Introduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands

MatLab Just a beginning

Matlab Introduction. Scalar Variables and Arithmetic Operators

INTRODUCTION TO NUMERICAL ANALYSIS

MATLAB Tutorial The Basics

Introduction to MATLAB

ECE Lesson Plan - Class #3 Script M-files, Program Control, and Complex Numbers

Some elements for Matlab programming

COGS 119/219 MATLAB for Experimental Research. Fall 2016 Week 1 Built-in array functions, Data types.m files, begin Flow Control

MATLAB GUIDE UMD PHYS401 SPRING 2012

Boolean Logic & Branching Lab Conditional Tests

Operators in C. Staff Incharge: S.Sasirekha

CS129: Introduction to Matlab (Code)

Programming for Experimental Research. Flow Control

Introduction to Matlab for Econ 511b

Octave Tutorial Machine Learning WS 12/13 Umer Khan Information Systems and Machine Learning Lab (ISMLL) University of Hildesheim, Germany

Matlab Review. Dr. Mark Glauser, Created by: David Marr. Mechanical Engineering Syracuse University. Matlab Review p.

Introduction to Matlab

Introduction to MatLab. Introduction to MatLab K. Craig 1

CME 192: Introduction to Matlab

Laboratory 0 Week 0 Advanced Structured Programming An Introduction to Visual Studio and C++

Dr Richard Greenaway

INTRODUCTION TO MATLAB

MATLAB for beginners. KiJung Yoon, 1. 1 Center for Learning and Memory, University of Texas at Austin, Austin, TX 78712, USA

MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

7 Control Structures, Logical Statements

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

Introduction to MATLAB

MATLAB Tutorial. Mohammad Motamed 1. August 28, generates a 3 3 matrix.

SECTION 5: STRUCTURED PROGRAMMING IN MATLAB. ENGR 112 Introduction to Engineering Computing

MATLAB COURSE FALL 2004 SESSION 1 GETTING STARTED. Christian Daude 1

Matlab Tutorial. Get familiar with MATLAB by using tutorials and demos found in MATLAB. You can click Start MATLAB Demos to start the help screen.

Digital Image Analysis and Processing CPE

DEPARTMENT OF MATHS, MJ COLLEGE

Dr Richard Greenaway

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

Course Layout. Go to follow instr. Accessible within campus (only for the first download)

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

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

AMATH 352: MATLAB Tutorial written by Peter Blossey Department of Applied Mathematics University of Washington Seattle, WA

Introduzione a MatLab. Prof. Sebastiano Battiato

Math 98 - Introduction to MATLAB Programming. Fall Lecture 1

Computer Vision. Matlab

Transcription:

Compact Matlab Course MLC.1 15.04.2014

Matlab Command Window Workspace Command History Directories MLC.2 15.04.2014

Matlab Editor Cursor in Statement F1 Key goes to Help Information MLC.3 15.04.2014

Elementary Statements Pos. Command Explanations 1 ; Behind a statement suppress outputs 2 x = 5 x assigning the value 5 3 Continuation sign to the visual structuring of the program code 4 % Comment Comments for documentation 5 who Listing variables 6 whos Listing variables in detail 7 clear all Delete Matlab environment completely MLC.4 15.04.2014

Vectors and Matrices I Pos. Command Explanations 1 s = [6;7;9]; Producing column vector; Semicolon separate lines 2 z = [1 2 3 4 5]; Producing row vector z = [1,2,3,4,5]; 3 y = 2:5; : Operator produces row vector with elements from 2 to 5 4 y = 1:2:9; : : Operators produce row vector from 1 to 9 one increment of 2 5 A = [1,2,3; 4,5,6]; Entering matrix. Comma or blank separate new line generates elements and semicolon 6 e = A(3,4); Extracting or assigning element B(1,2)=e; [1] All numbers can be symbolic expressions which imply calculations themselves again. MLC.5 15.04.2014

Vectors and Matrices II Pos. Command Explanations 7 s = A(:,2); Column from matrix extract or assign B(:,3)=s; 8 z = A(4,:); Extracting or assigning row from matrix D(3,:)=z; 9 Z=zeros(M,N); Producing null matrix 0 10 E=eye(M); Producing identity matrix E 11 [M,N] = size(m) M,N Dimension of the matrix 12 v = s Transposition operator both for vectors and matrices MLC.6 15.04.2014

Graphics Pos. Command Explanations 1 plot(x,y); Linear x/y graph 2 loglog(x,y); double logarithmic graph 3 semilogx(x1,y1, ) single logarithmic graph for x axis 4 semilogy(x1,y1 ) single logarithmic graph for y axis 5 surfl(x,y,z) 3D graph with shading 6 shading interp Activating shading interpolation 7 colormap(gray) Using colour table gray 8 figure; Producing a new output image 9 imshow(i,[0 255]); Grey value picture with 256 grey levels (1 Byte pro Pixel) MLC.7 15.04.2014

Matlab Machdefs und Tools Pos. Command Explanations 1 MachineDefs() Computer precision etc. 2 ReadDataFileMatrix(FileNameMatrix) C++ Streaming read Matrix FileNameMatrix 3 ReadDataMatrix(fid) C++ read Streaming fid MLC.8 15.04.2014

Operators MLC.9 15.04.2014

Arithmetic Operators Operator Description + Addition - Subtraction.* Multiplication./ Right division.\ Left division + Unary plus - Unary minus : Colon operator.^ Power.' Transpose ' Complex conjugate transpose * Matrix multiplication / Matrix right division \ Matrix left division ^ Matrix power MLC.10 15.04.2014

Relational Operators Operator < Less than <= Less than or equal to > Greater than >= Greater than or equal to == Equal to ~= Not equal to Description MLC.11 15.04.2014

Logical Operators Operator && Description Returns logical 1 (true) if both inputs evaluate to true, and logical 0 (false) if they do not. Returns logical 1 (true) if either input, or both, evaluate to true, and logical 0 (false) if they do not Logical Operation A & B and(a, B) A B or(a, B) ~A not(a) Equivalent Function MLC.12 15.04.2014

Bit Wise Operator Operator Description Example & Returns 1 for every element location that is true (nonzero) in both arrays, and 0 for all other elements. A & B = 01001 Returns 1 for every element location that is true (nonzero) in either one or the other, or both arrays, and 0 for all other elements. A B = 11101 ~ Complements each element of the input array, A. ~A = 10010 xor Returns 1 for every element location that is true (nonzero) in only one array, and 0 for all other elements. xor(a,b) = 10100 MLC.13 15.04.2014

Control Structures MLC.14 15.04.2014

if then else if/elseif/else Execute statements if condition is true Syntax if expression statements elseif expression statements else Statements end % Respond to command-line input. % Because the input string % could be more than one character, % use strcmp rather than == to % test for equality reply = input('would you like to see an echo? (y/n): ', 's'); if strcmp(reply,'y') disp(reply) end MLC.15 15.04.2014

switch switch/case/otherwise Switch among several cases based on expression Syntax switch switch_expression case case_expression statements case case_expression statements : otherwise statements end % Conditionally display different text % depending on a value entered at % the command line mynumber = input('enter a number:'); switch mynumber case -1 disp('negative one'); case 0 disp('zero'); case 1 disp('positive one'); otherwise disp('other value'); end MLC.16 15.04.2014

for For Execute statements specified number of times Syntax for index = initval:step:endval program statements : end % Step by increments of -0.1, and display the step values for s = 1.0: -0.1: 0.0 disp(s) end MLC.17 15.04.2014

while while Repeatedly execute statements while condition is true Syntax while expression statements end % Find the first integer n for which factorial(n) is a 100-digit number n = 1; nfactorial = 1; while nfactorial < 1e100 n = n + 1; nfactorial = nfactorial * n; end MLC.18 15.04.2014

Debugging with Matlab MLC.19 15.04.2014

Debugging I Cursor in Line F12 Key sets and delete Break Point Go to Main Program Activate Run or activate Main Program via the Matlab command line MLC.20 15.04.2014

Debugging II Breakpoints Continue / F5 Step / F10 Step In / F11 Step Out / Shift + F11 Run to Cursor MLC.21 15.04.2014

Debugging III Step / F10 Cursor to theta1 shows the value MLC.22 15.04.2014

END MLC.23 15.04.2014