class2a_matlab_activities_engr195(II)s10

class2a_matlab_activities_engr195(II)s10 - ENGR 195(II...

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

View Full Document Right Arrow Icon
ENGR 195(II) – Spring 2010 Activity 1 Class 2a Activity 1 - Assigning Vectors and Performing Mathematical Operations with Vectors (Estimated Time: 20 minutes) In this exercise, you and a partner will learn to assign vectors and perform vector element-by- element mathematical operations. 1. At the MATLAB prompt in the Command window, create a variable called Ascalar and assign it the value 3 . 2. Now you will learn to assign vectors to variable names. Vectors are just a series of numbers that are related in some way. a. At the MATLAB prompt in the Command Window, you will create a row vector called Arowvector and assign Arowvector the values starting from 0 and ending at 3 in increments of 1 . Create the row vector by typing (using square brackets): Arowvector = [0 1 2 3] You could also create Arowvector by typing: Arowvector = [0,1,2,3] b. Create a second row vector called Browvector with four elements of your choice. To keep this manageable, the value of each element should be an integer between -5 and 5. Browvector = __________________________________________ c. Create a third row vector called Crowvector with three elements of your choice. The value of each element should be an integer between -5 and 5. Crowvector = __________________________________________ d. Create a column vector called Acolvector . Assign Acolvector the same values assigned to Arowvector . To do this, type: Acolvector = [0;1;2;3] Note that the syntax for assigning a column vector is slightly different than the syntax for assigning a row vector. A semicolon indicates when a new row should start in a column vector. Because a column vector, by definition, has only one column, a semicolon is
Image of page 1

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

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