conatinate matrix which is getting updated in loop

1 回表示 (過去 30 日間)
sita
sita 2015 年 3 月 17 日
コメント済み: Michael Haderlein 2015 年 3 月 18 日
hi,
for s=1:500
consall1(s,:,:)=[cons1, cons2, cons31, cons32, cons33, cons34];
end
from above mentioned for loop.I need a single matrix with 6 rows.please reply with your ideas.
sita
  4 件のコメント
sita
sita 2015 年 3 月 18 日
my cons1....cons34 changes in loop so after every iteration i have different consall1..i want to combine them with 500 rows 6 coloms..soryy for not explaining clearly
Michael Haderlein
Michael Haderlein 2015 年 3 月 18 日
So besides the needless introduction of a third dimension, what is wrong with your code fragment? I assume that you cannot vectorize the calculation of cons1,...34. To speed up a bit (though it won't make a big difference here), you can preallocate consall1 with
consall1=zeros(500,6);
and then start overwriting the zeros with the values in the loop.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by