Clear Filters
Clear Filters

Matrix Manipulations 1 (extracting elements for new matrices) E

27 views (last 30 days)
The test suite generates a random M x N matrix with a random number of rows and columns that is assigned to the variable A . The element values of the matrix are random double precision numbers that fall in the range from -10 to 10. The matrix has between 5 and 10 rows and between 5 and 10 columns. Assuming A is defined in the workspace, write a script with commands to perform the operations described below and assign the results to the indicated variable names.
- Create a new 2 x N matrix, B, that consists of the first and last rows of A.
- Create a new 2 x 2 matrix, C, that consists of the elements at the four corners of A.
- Create a new M-1 x N-1 matrix, D, that consists of the second through last columns in the second through last rows of A.

Answers (1)

Sanket Karnik
Sanket Karnik on 15 Feb 2017
I understand that you need help in indexing into a matrix. Please refer to the following link: https://www.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.html
This article explains about how to index into a Matrix. The article also has many examples which will help you in understanding different types of indexing, which you can use to solve the question.

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!