math245lab02

math245lab02 - Math245 Lab set #2 Fall 2008 Introduction to...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Math245 Lab set #2 Fall 2008 Page 1 Introduction to Matlab Basics 2 1. Vector data handling and manipulation a=[1 -1 3 5 2] now for example, create a row vector 'a' with length 5 a = 1 -1 3 5 2 length(a) gives you total number of elements in vector a ans = 5 a(4) displays 4 th element of vector a ans = 5 a(4)=a(4)/2 divides 4 th element by 2 a = 1.0000 -1.0000 3.0000 2.5000 2.0000 a(end) this refers to the end element of vecotor a, that is a(5) ans = 2 max(a) gives maximum value of element in vector a ans = 3 min(a) gives minimum value of element in vector a ans = -1 mean(a) gives average value of elements in vector a ans = 1.5000 sum(a) summation of all elements in vector a ans = 7.5000 a' putting quotation gives you transpose of vector a. (exchange row to column or column to row) ans = 1.0000 -1.0000 3.0000 2.5000 2.0000
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Math245 Lab set #2 Fall 2008 Page 2 2. Matrix data handling and manipulation A=[1 3 6 4; 3 8 0 1; 2 4 7 9] we create 3 × 4 (3 rows and 4 columns) matrix for example A = 1 3 6 4 3 8 0 1 2 4 7 9 size(A) gives you the size of matrix A ans = 3 4 the first value is the number of rows and second
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

math245lab02 - Math245 Lab set #2 Fall 2008 Introduction to...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online