plugin-math245lab02

plugin-math245lab02 - Math245 Lab set #2 Spring 2009...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Math245 Lab set #2 Spring 2009 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 Page 1 Math245 Lab set #2 Spring 2009 2.0000 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 is number of columns A(2, 3) refers the element on 2 nd row and 3 rd column ans = 0 A(:, 2) this refers all elements in 2 nd column of matrix A. the colon ':' means 'all' indecies. in this case ':' means all rows.case ':' means all rows....
View Full Document

This note was uploaded on 06/01/2009 for the course MATH 245 taught by Professor Alexander during the Spring '07 term at USC.

Page1 / 6

plugin-math245lab02 - Math245 Lab set #2 Spring 2009...

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