MAT-03B Array Accessing and String HW

MAT-03B Array Accessing and String HW

MATLAB 5th Edition: Chapter 2, Problems 19, 34, 36, and Problem A (below)

Special Instructions:

Comment the code; you do not need to comment to explain every single step you do. Comment when you need to explain logic. From this assignment forward, you are to comment your code or points will be deducted.

Problem 19:

· Create Codd with two separate references to vctC for the beginning and ending elements,

i.e. extract the first and second groups of elements separately and put together by

Codd = [first set of elements from vctC, second set of elements from vctC]

· Create Ceven with only one reference to vctC for all required elements,

i.e Ceven = vctC(list of elements)

Problem A:

1.  Create and assign to variables the strings ‘My class is: ’ and ‘ENGR1181.01’

2.  Concatenate the two strings to create a single string ‘My class is: ENGR1181.01’ and assign the new string to a new variable. Display the results using disp()

3.  Extract the ‘1181.01’ portion from the string created in step 2 and assign it to a new variable. Display the results using disp()

Problem 34:

Do not create array A, instead create array B with the following instructions: the first and second rows of array B using the colon operator and the third using linspace. The arrays for part a needs to be created using only one reference to array B (the letter B may only appear one time on the RHS, you will have to use the reshape command for this). The arrays for all parts, a, b, and c, need to be created by extracting elements from the array B. Use colon operator(s) and [ ] where appropriate.

Problem 36:

Create the first row of array E using the ones() command (hint: multiplying the ones command such as: x*ones(1,2) will give [x x]), the second and third row with the colon operator, and the fourth using linspace. The array for parts a and b need to be created using only one reference to array E (the letter E may only appear one time on the RHS). The arrays for both parts, a and b, need to be created by extracting elements from the array E. Use colon operator(s), [ ], and transpose operator where appropriate.

Do not directly type in elements for all the problems