Putting column vector in a matrix

2 vues (au cours des 30 derniers jours)
Ahmad Hasnain
Ahmad Hasnain le 13 Déc 2018
Commenté : madhan ravi le 13 Déc 2018
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?

Réponse acceptée

madhan ravi
madhan ravi le 13 Déc 2018
Modifié(e) : madhan ravi le 13 Déc 2018
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 commentaires
Ahmad Hasnain
Ahmad Hasnain le 13 Déc 2018
Thanks, it works fine.
madhan ravi
madhan ravi le 13 Déc 2018
Anytime :)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by