Create the following matrix M: 1 7 13 19 25 ?-3 9 15 21 27 5 11 17 2329By writing one command and using the colon to address range of elements (do not type individual elements explicitly), use the matrix M to: (a) Create a five-element row vector named Va that contains the elements of the third row of M. (b) Create a three-element column vector named Va that contains the elements of the fourth column of M. (c) Create an eight-element row vector named Vc that contains the elements of the second row of M followed by the elements of the third column of M.

Respuesta :

Answer:

Matlab code is:

>> [tex]M=reshape(1:2:29, 3,5)[/tex]

>> [tex]\% (a)[/tex]

>> [tex]Va=M(3,:)[/tex]

>> [tex]\% (b)[/tex]

>> [tex]Vb=M(:,4)[/tex]

>> [tex]\% (c)[/tex]

>> [tex]Vc=[M(2,:) M(:,3)'][/tex]

Explanation:

>>[tex]\% \ Making\ the\ Matrix\ With\ required\ terms\ 1\ to\ 29\ with\ spaces\ of\ 5\ in\ three\ rows[/tex]

>> [tex]M=reshape(1:2:29, 3,5)[/tex]

[tex]M =[/tex]

              1   7  13  19  25

              3  9  15  21  27

              5  11  17  23  29

>> [tex]\% (a)[/tex]

>>[tex]\%\ Slicing\ M\ \ from\ third\ row\ till\ end[/tex]

>> [tex]Va=M(3,:)[/tex]

[tex]Va =\\\ 5\ 11\ 17\ 23\ 29[/tex]

>> [tex]\% (b)[/tex]

>>[tex]\% \ Slicing\ the\4th\ column\ of\ M\ matrix\[/tex]

>> [tex]Vb=M(:,4)[/tex]

[tex]Vb =\\ 19\\ 21\\ 23\\[/tex]

>> [tex]\% (c)[/tex]

>>[tex]\% \ slicing\ the\ 2nd\ row\ and\ 3rd\ column\ of\ M\ Matrix\ and\ combining\ them\ to\ make\ a\ row\ matrix[/tex]

>> [tex]Vc=[M(2,:) M(:,3)'][/tex]

[tex]Vc =\\ 3\ 9\ 15\ 21\ 27\ 13\ 15\ 17[/tex]

>>

The code is tested and is correct. If you put a semi colon ' ; ' at the end of every statement then your answer will be calculated but matlab doesn't show it until you ask i.e. typing the variable (Va, Vb, Vc )and press enter.

ACCESS MORE