Reading a matrix in storage order

Mark Yourself Question

  1. Grab a piece of paper and try this problem yourself.
  2. When you're done, check the "I have answered this question" box below.
  3. View the solution and report whether you got it right or wrong.

In MATLAB,


MATLAB
B = [1 2 3; 4 5 6];


a) State size(B), numel(B) and length(B).


b) Write out the column vector produced by B(:) and give its size.


c) What value does B(5) return, and which subscripts B(i,j) refer to the same element?


d) Find the linear index k for which B(k) is the same element as B(2,2), and state its value.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Scalars, Vectors, Matrices Questions: