plugin-math245lab02

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

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

View Full Document Right Arrow Icon
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
Image of page 1

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

View Full Document Right Arrow Icon
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.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern