I need to write the code that turns a row vector into a matrix. For example, if I had a = 1 2 3 4 5 6 7 8 9
, I want the matrix to be:
m = [1 2 3;
4 5 6;
7 8 9]
I have this, which doesn't work. Can anyone please assist me?
for i=1:length(a)
m = a(i);
i = i + 1;
end
Moreover, I am not allowed to use any of Matlab's built-in functions (such as reshape
).