how to save each loop data in consecutive rows?

4 ビュー (過去 30 日間)
sandy
sandy 2014 年 3 月 13 日
回答済み: David Sanchez 2014 年 3 月 13 日
i need to store the each iteration values in consecutive rows.how it is possible in matlab?
for i =1:3
a=rand(3,2);
b = reshape(a.',1,[]);
end
ex:
i=1; b= 0.1174 0.4242 0.2967 0.5079 0.3188 0.0855
i=2: b= 0.1174 0.4242 0.2967 0.5079 0.3188 0.0855
i=3; b= 0.9133 0.2619 0.7962 0.3354 0.0987 0.6797
output should be a variable(3*6)
0.1174 0.4242 0.2967 0.5079 0.3188 0.0855
0.1174 0.4242 0.2967 0.5079 0.3188 0.0855
0.9133 0.2619 0.7962 0.3354 0.0987 0.6797

採用された回答

Roger Stafford
Roger Stafford 2014 年 3 月 13 日
編集済み: Roger Stafford 2014 年 3 月 13 日
b = zeros(3,2*3);
for k = 1:3
a = rand(3,2);
b(k,:) = reshape(a.',1,[]);
end
Note: Your output is 3 by 6, not 3 by 5.
  1 件のコメント
sandy
sandy 2014 年 3 月 13 日
thankyou...it works

サインインしてコメントする。

その他の回答 (1 件)

David Sanchez
David Sanchez 2014 年 3 月 13 日
your_output = zeros(3,6); % initialization of variable
for i =1:3
a=rand(3,2);
b = reshape(a.',1,[]);
your_output(i,:) = b;
end
your_output =
0.6787 0.3922 0.7577 0.6555 0.7431 0.1712
0.7060 0.0462 0.0318 0.0971 0.2769 0.8235
0.6948 0.0344 0.3171 0.4387 0.9502 0.3816

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by