Generate the following matrix without typing in each individ

Generate the following matrix without typing in each individual element. Utilize the colon operator, and other built-in MATLAB functions. 1 14 7 15 3 28 7 26 5 42 7 37 7 56 7 48 From the above matrix, use MATLAB commands to find the elements (or series of elements) listed below: 2 nd row, 3rd column 1 st row, 4th column All rows in 2nd column All columns in 3rd row All columns in 2 nd and 4th row All rows in 1st and 4th columns The 2nd through 4th rows in the 1st through 3rd columns The 2nd through 3rd rows in the 2nd through 3rd columns The 1st and 4th rows in the 2nd and 4th columns

Solution

A=[1:2:7;14:14:56;7.*ones(1,4);15:11:48];
disp(\'matrix\')
A=A\'
disp(\'A(2,3)\')
A(2,3)
disp(\'A(1,4)\')
A(1,4)
disp(\'all rows 2nd column\')
A(1:end,2)
disp(\'all rows 2nd column\')
A(3,1:end)
disp(\'2nd,4th row, all columns\');
A([2 4],1:end)
disp(\'all rows of 1st an 4th column\')
A(1:end,[1 4])
disp(\'2nd to 4th rows of 1st to 3rd column\');
A(2:4,1:3)
disp(\'2nd to 3rd rows of 2nd to 3rd column\');
A(2:3,2:3)
disp(\'1,4 rows of 2,4 columns\');
A([1 4],[2 4])

>> m18
matrix

A =

     1    14     7    15
     3    28     7    26
     5    42     7    37
     7    56     7    48

A(2,3)

ans =

     7

A(1,4)

ans =

    15

all rows 2nd column

ans =

    14
    28
    42
    56

all rows 2nd column

ans =

     5    42     7    37

2nd,4th row, all columns

ans =

     3    28     7    26
     7    56     7    48

all rows of 1st an 4th column

ans =

     1    15
     3    26
     5    37
     7    48

2nd to 4th rows of 1st to 3rd column

ans =

     3    28     7
     5    42     7
     7    56     7

2nd to 3rd rows of 2nd to 3rd column

ans =

    28     7
    42     7

1,4 rows of 2,4 columns

ans =

    14    15
    56    48

>>

 Generate the following matrix without typing in each individual element. Utilize the colon operator, and other built-in MATLAB functions. 1 14 7 15 3 28 7 26 5
 Generate the following matrix without typing in each individual element. Utilize the colon operator, and other built-in MATLAB functions. 1 14 7 15 3 28 7 26 5

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site