# HW2prob1 - threes = 8:3:38(c Construct a vector"reverse" containing numbers starting at 20 and counting backwards by ones to 10 Use the

This preview shows page 1. Sign up to view the full content.

Sheet1 Page 1 %========================================================================== % PROBLEM 1. Creating Vectors %-------------------------------------------------------------------------- % % For the following exercises, do not use the direct entry method to % construct the vectors. % clear clc % (a) Construct a vector containing all of the even numbers between 6 and % 33, inclusive of the endpoints. Store your answer in the variable % "evens". Use the range specification method. (Note: 33 is not an % even number). evens = 6:2:33 % (b) Construct a vector, "threes", containing every third number starting % with 8 and ending at 38. Use the range specification method.
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: threes = 8:3:38 % (c) Construct a vector, "reverse", containing numbers starting at 20 and % counting backwards by ones to 10. Use the range specification % method. reverse = 20:-1:10 % (d) Construct a vector, "theta", containing 100 evenly spaced values % between -pi to pi. Use linspace, not range specification. theta = linspace(-pi,pi,100) % (e) Construct a vector, "myZeros", containing 15 elements, all of which % are zeros. Use the built-in zeros() function myzeros = zeros(1,15) % (f) Construct a vector, "random", containing 15 randomly generated % numbers between 1 and 2. Use the built-in rand() function. random = rand(1,15) + 1...
View Full Document

## This note was uploaded on 07/06/2009 for the course CS 1371 taught by Professor Stallworth during the Fall '08 term at Georgia Institute of Technology.

Ask a homework question - tutors are online