Matrix formed by Vectors?Easy question.
1 次查看(过去 30 天)
显示 更早的评论
I have a matrix size=10x10. And I want to obtain each column as a vector. Or vectors will create a matrix. How can I do that? Thanks in advance.
0 个评论
采纳的回答
Bjorn Gustavsson
2013-7-16
Yup, simple:
M =randn(10);
for i1 = 1:size(M;2)
V{i1} = M(:,i1);
end
Then you have your vectors in the cells of V.
The other direction:
M = [v1,v2,v3,....,vN];
There vN has to be column vectors.
HTH
0 个评论
更多回答(1 个)
Azzi Abdelmalek
2013-7-16
v=[1 2 3;4 5 6;7 8 9]
v1=v(:,1) % first column
v2=v(:,2)
v3=v(:,3)
% horizontal concatenation
v=[v1 v2 v3]
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!