MATLAB: If I have a matrix of 100 rows by 5 columns, how can I make it a 1 row x 500 column matrix, where each row (1×5) is placed one after the other to make a 1×500 matrix

matrix manipulation

[r,c] = size(data);%(100 rows by 5 columns)
datanew = zeros(1,500)%
for i = 1:r
startcol = (1+(i-1)*5);
endcol = (5*i);
datanew(1,data(1,startcol:endcol)); %I get an error "Subscript indices must either be real positive integers or logicals." But data(1,startcol:endcol) does contain the correct 1×5 data, therefore, uncertain why the error.
end

Best Answer

datanew = reshape(data',1,[]);