Putting column vector in a matrix

조회 수: 1 (최근 30일)
Ahmad Hasnain
Ahmad Hasnain 2018년 12월 13일
댓글: madhan ravi 2018년 12월 13일
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{:}]
  댓글 수: 2
Ahmad Hasnain
Ahmad Hasnain 2018년 12월 13일
Thanks, it works fine.
madhan ravi
madhan ravi 2018년 12월 13일
Anytime :)

댓글을 달려면 로그인하십시오.

추가 답변 (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