How can I have n randomly generated vectors?
1 次查看(过去 30 天)
显示 更早的评论
Hi, I want to generate n random vectors. The problem is I put it in the loop and the vector is being replaced in every run, but I need to have all of the n vectors.
for n= 1:50
A=rand(1,5);
end
How can I have n random vectors as an output?
0 个评论
采纳的回答
更多回答(1 个)
Image Analyst
2016-10-2
Store the vectors in rows of A
A = rand(50, 5);
Anytime you need one of the vectors, just reference a row of A
thisVector = A(row, :);
5 个评论
Image Analyst
2016-10-2
Try one of these options:
m = magic(3)
% Get m going down columns
mRow = m(:)'
% Get m going across rows
temp = m';
mRow = temp(:)'
m =
8 1 6
3 5 7
4 9 2
mRow =
8 3 4 1 5 9 6 7 2
mRow =
8 1 6 3 5 7 4 9 2
另请参阅
类别
在 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!