Create a row vector vA=1:3:34 that has 12 elements. Then, create a new nine-element vector vB from the elements of vA such that the first five elements are the first five elements of the vector vA, and the last four are the last four elements of the vector vA. Use the colon symbol to address a range of elements. (Do not type the elements of the vector vA explicitly.)

Respuesta :

Step-by-step explanation:

Create a row vector vA=1:3:34 that has 12 elements.

Matlab Code:

vA = [1:3:34]

Where vA = [starting element:difference:ending element]

Ouput:

vA =    1     4     7    10    13    16    19    22    25    28    31    34

Create a new nine-element vector vB from the elements of vA such that the first five elements are the first five elements of the vector vA, and the last four are the last four elements of the vector vA

Matlab Code:

% get first five elements from vector vA

vB1 = vA(1:5)

% get last four elements from vector vA

vB2 = vA(9:12)

% combine them together to form row vector vB

vB = [vB1, vB2]  (comma or space both are fine)

Ouput:

vB1 =       1     4     7    10    13  

vB2 =     25    28    31    34

vB =      1     4     7    10    13    25    28    31    34

ACCESS MORE