MATLAB: How to extract rows of numbers from a matrix and put them all in one long vector

homeworkMATLABmatrix manipulation

So, here's my task: I have a matrix that is 115×12 (years and months… not that it matters!) I want to take row 2 and attach it at the end of row 1, and row 3 at the end of that, etc., to make one long vector (1×1380) in another variable. So we have something to talk about, let's name the original matrix "Nile." Thanks!!

Best Answer

  • See if this does what you want:
    Nile = repmat([1:12], 115, 1); % Create Data
    NileV = reshape(Nile', 1, numel(Nile)); % Reshape To Vector