Script started on Thu 25 Aug :00:40 PM CDT

Similar documents
Matlab Workshop I. Niloufer Mackey and Lixin Shen

BRUNO WELFERT Arizona State University AND. R. Kent Nagle. University of South Florida. Edward B. Saff. Vanderbilt University. A.

Programming in MATLAB

National Workshop on LaTeX and MATLAB for Beginners

LAB 1 General MATLAB Information 1

Introduction to Scientific and Engineering Computing, BIL108E. Karaman

General MATLAB Information 1

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

A. Matrix-wise and element-wise operations

MATLAB Workshop Dr. M. T. Mustafa Department of Mathematical Sciences. Introductory remarks

Arithmetic and Logic Blocks

Lecture 1: What is MATLAB?

Introduction to MATLAB

GRAPH 4.4. Megha K. Raman APRIL 22, 2015

Introduction to MATLAB

Introduction to MATLAB

Ebooks Chemical Engineering

MATLAB Constants, Variables & Expression. 9/12/2015 By: Nafees Ahmed

Introduction to MATLAB for CSE390

Consider this m file that creates a file that you can load data into called rain.txt

A very short introduction to Matlab and Octave

A General Introduction to Matlab

MATLAB: a Brief Introduction. by Robert L. Rankin

Built-in Types of Data

Introduction to Matlab

# Import constants pi2, pip2, pip4 (2*pi, pi/2, pi/4). use Math::Trig ':pi';

Section 5.3 Graphs of the Cosecant and Secant Functions 1

Introduction to GNU-Octave

Scientific Computing Lecture 1: MATLAB fundamentals

Dr Richard Greenaway

PIV Programming. Today s Contents: 1. Matlab Programming 2. An example of PIV in Matlab code 3. EDPIV 4. PIV plugin for ImageJ 5.

Chapter 1 MATLAB Preliminaries

Outline. CSE 1570 Interacting with MATLAB. Outline. Starting MATLAB. MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An.

Introduction to MATLAB

Introduction to Matlab. Matlab variable types. Matlab variable types. Matlab variable types. Notes. Eugeniy E. Mikhailov. Lecture 02. Notes.

Introduction to MATLAB

Inlichtingenblad, matlab- en simulink handleiding en practicumopgaven IWS

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

The Official Guide to Easy Graphing. ParaGraph. Ver Congratulations Graphing just got easier.

The Graphing Calculator

# Import constants pi2, pip2, pip4 (2*pi, pi/2, pi/4). use Math::Trig ':pi';

Outline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline. MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An.

A very brief Matlab introduction

Using GNU Octave for Numerical Methods

A QUICK INTRODUCTION TO MATLAB

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

GNU libmatheval manual

Math 1330 Section 5.3 Graphs of the Tangent, Cotangent, Secant, and Cosecant Functions

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

Julia Calculator ( Introduction)

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

Outline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline (Cont d) MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An

A QUICK INTRODUCTION TO MATLAB. Intro to matlab getting started

Lecturer: Keyvan Dehmamy

Basic types and definitions. Chapter 3 of Thompson

Lecture 14. Daily Puzzle. Math in C. Rearrange the letters of eleven plus two to make this mathematical statement true. Eleven plus two =?

x,,, (All real numbers except where there are

POLYMATH POLYMATH. for IBM and Compatible Personal Computers. for IBM and Compatible Personal Computers

Single row numeric functions

Finding, Starting and Using Matlab

Section 6.2 Graphs of the Other Trig Functions

Computer Programming in MATLAB

Fundamentals of MATLAB Usage

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

Introduction to MATLAB

PROGRAMMING WITH MATLAB DR. AHMET AKBULUT

Introduction to Scilab

MYSQL NUMERIC FUNCTIONS

Introduction to MATLAB Programming

Introduction to MATLAB 7 for Engineers

Macro Programming Reference Guide. Copyright 2005 Scott Martinez

Introduction to Scilab

Introduction to Scilab

This is called the horizontal displacement of also known as the phase shift.

Some elements for Matlab programming

Matlab as a calculator

short-reference.mht 1/ /WK/

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

I. Introduction to Programming Using MATLAB

1. GRAPHS OF THE SINE AND COSINE FUNCTIONS

ECET 264 C Programming Language with Applications

Sum and Difference Identities. Cosine Sum and Difference Identities: cos A B. does NOT equal cos A. Cosine of a Sum or Difference. cos B.

A Guide to Using Some Basic MATLAB Functions

Math 2250 MATLAB TUTORIAL Fall 2005

AMS 27L LAB #1 Winter 2009

INTRODUCTION TO MATLAB. Padmanabhan Seshaiyer

Mentor Graphics Predefined Packages

Introduction to Programming

C Functions. 5.2 Program Modules in C

How to Design Programs Languages

ELEMENTARY MATLAB PROGRAMMING

CT 229 Java Syntax Continued

Trigonometric Functions of Any Angle

1001ICT Introduction To Programming Lecture Notes

Graphs of Other Trig Functions

Math 144 Activity #3 Coterminal Angles and Reference Angles

Matlab for Chemists. Theoretical Chemistry Radboud University The Netherlands

VARIABLES Storing numbers:

Precalculus Solutions Review for Test 6 LMCA Section

Function Example. Function Definition. C Programming. Syntax. A small program(subroutine) that performs a particular task. Modular programming design

Transcription:

Script started on Thu 25 Aug 2016 02:00:40 PM CDT < M A T L A B (R) > Copyright 1984-2014 The MathWorks, Inc. R2014a (8.3.0.532) 64-bit (glnxa64) February 11, 2014 To get started, type one of these: helpwin, helpdesk, or demo. For product information, visit www.mathworks.com. >> x = 5 x = 5 Your variables are: x >> x = y = x + 5 y = 10 >> y = x*5 y = 25 >> y = x^2 y = >> x x = 25 5 >> y = x^3

y = 125 >> y = 3 + 55-62 + 4-5 y = -5 >> y = 3*2+3*2 y = 12 >> y = 3* 2+3 * 2 y = 12 >> y = 3* (2+3) * 2 y = 30 >> y = 5 y = 5 >> x = 3 x = 3 >> x/y 0.6000 >> y/x 1.6667 >> x\y Commented [LS1]: X divides into y. Seldom used. Not as intuitive.

>> y\x 1.6667 0.6000 >> help elfun Elementary math functions. Trigonometric. sin - Sine. sind - Sine of argument in degrees. sinh - Hyperbolic sine. asin - Inverse sine. asind - Inverse sine, result in degrees. asinh - Inverse hyperbolic sine. cos - Cosine. cosd - Cosine of argument in degrees. cosh - Hyperbolic cosine. acos - Inverse cosine. acosd - Inverse cosine, result in degrees. acosh - Inverse hyperbolic cosine. tan - Tangent. tand - Tangent of argument in degrees. tanh - Hyperbolic tangent. atan - Inverse tangent. atand - Inverse tangent, result in degrees. atan2 - Four quadrant inverse tangent. atan2d - Four quadrant inverse tangent, result in degrees. atanh - Inverse hyperbolic tangent. sec - Secant. secd - Secant of argument in degrees. sech - Hyperbolic secant. asec - Inverse secant. asecd - Inverse secant, result in degrees. asech - Inverse hyperbolic secant. csc - Cosecant. cscd - Cosecant of argument in degrees. csch - Hyperbolic cosecant. acsc - Inverse cosecant. acscd - Inverse cosecant, result in degrees. acsch - Inverse hyperbolic cosecant. cot - Cotangent. cotd - Cotangent of argument in degrees. coth - Hyperbolic cotangent. acot - Inverse cotangent. acotd - Inverse cotangent, result in degrees. acoth - Inverse hyperbolic cotangent. hypot - Square root of sum of squares.

Exponential. exp - Exponential. expm1 - Compute exp(x)-1 accurately. log - Natural logarithm. log1p - Compute log(1+x) accurately. log10 - Common (base 10) logarithm. log2 - Base 2 logarithm and dissect floating point number. pow2 - Base 2 power and scale floating point number. realpow - Power that will error out on complex result. reallog - Natural logarithm of real number. realsqrt - Square root of number greater than or equal to zero. sqrt - Square root. nthroot - Real n-th root of real numbers. nextpow2 - Next higher power of 2. Complex. abs angle complex conj imag real unwrap isreal cplxpair - Absolute value. - Phase angle. - Construct complex data from real and imaginary parts. - Complex conjugate. - Complex imaginary part. - Complex real part. - Unwrap phase angle. - True for real array. - Sort numbers into complex conjugate pairs. Rounding and remainder. fix - Round towards zero. floor - Round towards minus infinity. ceil - Round towards plus infinity. round - Round towards nearest integer. mod - Modulus (signed remainder after division). rem - Remainder after division. sign - Signum. >> floor(1.2939580) 1 >> ceil(1.2932930910) 2 >> round(1.3) 1

>> round(1.6) 2 >> round(1.5) 2 >> rem(3,5) 3 >> abs(-1) 1 >> abs(1) 1 >> pi 3.1416 >> 0/1 0 >> 1/0 Inf >> 0/0 NaN

ans 1x1 8 double y 1x1 8 double >> z = 3.1416 Commented [LS2]: This is type double. z = 3.1416 >> z1_int = int16(z) z_int = Commented [LS3]: With this, I type-cast the double into an integer of 16 bits and store it in z1_int, another variable. 3 ans 1x1 8 double y 1x1 8 double >> z_int8 = int8(10.1209) Commented [LS4]: z is still a double. Commented [LS5]: z_int is an integer of 16 bits. What is the largest number that int16 can represent? z_int8 = 10 ans 1x1 8 double y 1x1 8 double z_int8 1x1 1 int8 >> z_int8 = 1029020 z_int8 = 1029020

ans 1x1 8 double y 1x1 8 double z_int8 1x1 8 double >> intmin('int8') Commented [LS6]: Convenience (AND POTENTIAL PIT FALL!!) MATLAB automatically change the type of the variable z_int8 from an integer of 8 bits to a double of 8 bytes!! -128 >> intmax('int8') 127 >> intmin('uint8') 0 >> intmax('uint8') 255 >> y = 'a' y = a ans 1x1 1 uint8 y 1x1 2 char z_int8 1x1 8 double >> z_string = 'abcde' z_string = abcde

ans 1x1 1 uint8 y 1x1 2 char z_int8 1x1 8 double z_string 1x5 10 char Commented [LS7]: A vector of 5 characters. Length = 5. >> z_string = 'ab cde' z_string = ab cde ans 1x1 1 uint8 y 1x1 2 char z_int8 1x1 8 double z_string 1x6 12 char >> red_flag = 'true' red_flag = Commented [LS8]: This is assigning a string (i.e., a vector of characters) to the variable red_flag. true ans 1x1 1 uint8 red_flag 1x4 8 char y 1x1 2 char z_int8 1x1 8 double z_string 1x6 12 char >> red_flag = true red_flag = 1 Commented [LS9]: As a result, this is still a vector of characters. Commented [LS10]: This makes red_flag a logical variable. Commented [LS11]: This is a keyword. And it is represented internally in Matlab as 1.

ans 1x1 1 uint8 red_flag 1x1 1 logical y 1x1 2 char z_int8 1x1 8 double z_string 1x6 12 char >> red_flag = false red_flag = Commented [LS12]: See, now this is a logical variable. Commented [LS13]: Another keyword. Represented internally as 0. 0 >> num = int32('a') num = Commented [LS14]: American Standard Code for Information Exchange Every letter on our keyboard is represented by a number. 97 >> num = int32('b ) num = 98 >> num = int32( c') num = 99 >> num = int32('a ) num = 65 >> num = int32( B ) num = 66 >> num = int32('c ) num = 67 >> num = int32(? ) num =

63 >> num = int32('$ ) num = 36 >> num = int32('# ) num = 35 >> num = int32(' ) num = 32 >> char('abcd' + 1) Commented [LS15]: Cool!!! I can shift the characters by 1! bcde >> v = [1 2 3 4 5] v = 1 2 3 4 5 ans 1x4 8 char num 1x1 4 int32 red_flag 1x1 1 logical v 1x5 40 double y 1x1 2 char z_int8 1x1 8 double z_string 1x6 12 char >> v c = [1; 2; 3 ; ; 4; 5] c = 1 2 3 4

5 >> matrix 2 = [1 2; 3 4] m2 = 1 2 3 4 >> m3 = [1 2 3; 10 10 10] m3 = 1 2 3 10 10 10 >> m3 = [1 2 3; 10 10 10]]1]0]; 10 10 10 10]4; 10 10 10 10]; 10 10 10 10;]]7]]8]]9]]1]0]]] m3 = [1 2 3 4; 10 10 10 10; 7 8 9 10]] {Error: Unbalanced or unexpected parenthesis or bracket. } >> m3 = [1 2 3 4; 10 10 10 10; 7 8 9 10]]] m3 = 1 2 3 4 10 10 10 10 7 8 9 10 >> vec = [1: 5 1:5 vec = 1 2 3 4 5 >> vec = 1:2:11 vec = 1 3 5 7 9 11 >> vec 1 = 1:2:9 1 3 5 7 9 >> v2 = 11:17 v2 = 11 12 13 14 15 16 17

>> newvector = [v1 v2] newvector = 1 3 5 7 9 11 12 13 14 15 16 17 ans 1x4 8 char c 5x1 40 double m2 2x2 32 double m3 3x4 96 double newvector 1x12 96 double num 1x1 4 int32 red_flag 1x1 1 logical v 1x5 40 double v1 1x5 40 double v2 1x7 56 double vec 1x6 48 double y 1x1 2 char z_int8 1x1 8 double z_string 1x6 12 char >> newvector(1) 1 >> newvector(1)1) 2) 3 >> newvector newvector = 1 3 5 7 9 11 12 13 14 15 16 17 >> newvecotr tor[2] newvector[2] {Error: Unbalanced or unexpected parenthesis or bracket. } >> newcge vector(2)

3 >> newvector(6) 11 >> newvector(4:5 6( ) 7 9 11 >> newvectro([11 or([1 1 6 11]) >> ans' 1 11 16 1 11 16 >> newvector newvector = 1 3 5 7 9 11 12 13 14 15 16 17 >> newvector(5) 1) = 10 newvector = 10 3 5 7 9 11 12 13 14 15 16 17 >> newvector(13) = 11 1000 newvector = Columns 1 through 9 10 3 5 7 9 11 12 13 14 Columns 10 through 13 15 16 17 1000 >> newvector(13) = 1000) = 1000 5) = 1000

newvector = Columns 1 through 9 10 3 5 7 9 11 12 13 14 Columns 10 through 15 15 16 17 1000 0 1000 >> vecto 1 = [2 5 18 10] >> v1' 2 5 18 10 2 5 18 10 >> v1 v1' ' 2 5 18 10 >> v1' 2 5 18 10 >> v1' 2 5 18 10 >> v1'

2 5 18 10 >> v1' 2 5 18 10 >> v1' 2 5 18 10 >> mat = [2 4 3 1; 2 5 6] mat = >> mat(1) 4 3 1 2 5 6 4 >> mat(6) 6 >> mat(2) 2 >> mat(2)) 3) 3 >> mat(3) 4) 5

>> mat(4) 5) 1 >> mat mat = 4 3 1 2 5 6 >> rand2 (2) 0.8147 0.1270 0.9058 0.9134 >> rand(3) 0.6324 0.5469 0.1576 0.0975 0.9575 0.9706 0.2785 0.9649 0.9572 >> rand(1,30 ) 0.4854 0.8003 0.1419 >> zeros(3) 0 0 0 0 0 0 0 0 0 >> ones(3) 1 1 1 1 1 1 1 1 1 >> twos(3) {Undefined function 'twos' for input arguments of type 'double'. }

>> int mat = [100 77; 28 14] mat = 100 77 28 14 >> in mat(1) = 100 mat = 100 77 28 14 >> mat(1) = 1000 28 mat = 28 77 28 14 >> mat(1) = 28 ) = 2) = ) = 6 0 mat = >> mat mat = 28 77 60 14 28 77 60 14 >> mat(2,:) = [600 140] mat = 28 77 600 140 >> mat(:,2) = [777787 140000] mat = >> v1 28 7777 600 140000 2 5 18 10

>> lengtyh h(v1) 4 >> le length(mat) 2 >> size9 (mat) 2 2 >> matrix mymatr = [1 2 3; 9 10 11] mymat = 1 2 3 9 10 11 >> si z size(myamat mat) 2 3 >> reshape rto ot(mymat) {Undefined function 'rot' for input arguments of type 'double'. } >> rot90(mymat) 3 11 2 10 1 9 >> rot90 fliplr(k mymat) 3 2 1 11 10 9 >> flipud(mymat)

>> v = [] v = 9 10 11 1 2 3 [] >> m vec 1 2 5 18 10 >> [] [] ans 2x3 48 double c 5x1 40 double m2 2x2 32 double m3 3x4 96 double mat 2x2 32 double mymat 2x3 48 double newvector 1x15 120 double num 1x1 4 int32 red_flag 1x1 1 logical v 0x0 0 double v1 0x0 0 double v2 1x7 56 double vec 1x6 48 double y 1x1 2 char z_int8 1x1 8 double z_string 1x6 12 char >> vec = 1:5 vec = 1 2 3 4 5 >> vec(3) = [] vec =

1 2 4 5 >> exit [?1l>[1mcse[0m fac/lksoh> exit exit Script done on Thu 25 Aug 2016 03:16:37 PM CDT