Putting column vector in a matrix

4 次查看(过去 30 天)
for i = 1:N
for row = 1 : n
for col = 1:m
grad(row,col)= .... %%%% I get a n x m matrix %%%%
end
end
gradv = grad(:); %%% Now I convert the matrix in a column vector %%%
%%%% For the outer loop "for i = 1:N", I get a coulmn vector gradv on every iteration. I want to put it in a matrix N x (nxm).
gradmatrix = gradv (1); gradv(2);... gradv(N) %%% How do I do this?

采纳的回答

madhan ravi
madhan ravi 2018-12-13
编辑:madhan ravi 2018-12-13
gradv=cell(1,N);
for i = 1:N
for row = 1 : n
for col = 1:m
grad(row,col)= .... %%%% I get a n x m matrix %%%%
end
end
gradv{i} = grad(:);
end
celldisp(gradv)
matrix=[gradv{:}]

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by