EGR_102_Lab_05A_Vector_Creation___Plotti

EGR_102_Lab_05A_Vector_Creation___Plotti - MATLAB Vector...

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

View Full Document Right Arrow Icon
MATLAB ® Vector Creation and Plotting EGR 102 - Lab 05A 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
MATLAB Vectors MATLAB vectors: Collections of numbers lined up Ordered or random, one-dimensional groups of scalars Row vectors contain numbers in a single row Column vectors contain numbers in a single column Write one command to apply a cell-by-cell operation to all elements of a vector using the dot operator Able to perform same operation on each cell of a vector Perform all operations in one step EGR 102 - Lab 05A 2
Background image of page 2
Vector Creation Vectors are defined using brackets where , separate columns ; separate rows a = [1, 2, 4] b = [9; 2; 7] Each value in a vector is called an element Numbered from left to right or top to bottom EGR 102 - Lab 05A 3
Background image of page 3

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

View Full DocumentRight Arrow Icon
Vector Creation Concatenation: Create a new vector from two or more defined vectors >> x = [1,10]; >> y = [-10,x] >> z = [x,-10] The order of concatenation is important EGR 102 - Lab 05A 4
Background image of page 4
Vector Creation Concatenation: Distinguishes between column and row vectors >> a = [1;2;3]; >> b = [6;7;8]; >> c = [a;b] Use commas (,) to concatenate row vectors Use semicolons (;) to concatenate column vectors EGR 102 - Lab 05A 5
Background image of page 5

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

View Full DocumentRight Arrow Icon
Vector Creation Two alternative methods to create ordered vectors with equal spacing: 1. Built-in function linspace() Used when you know exact number of elements in a vector 2. Colon operator (:) Used when you know the spacing between elements Both produce a row vector with equal spacing EGR 102 - Lab 05A 6
Background image of page 6
linspace() function
Background image of page 7

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

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

Page1 / 22

EGR_102_Lab_05A_Vector_Creation___Plotti - MATLAB Vector...

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

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