フィルターのクリア

Matrix pre-allocation question

2 ビュー (過去 30 日間)
Jared
Jared 2018 年 10 月 19 日
編集済み: Matt J 2018 年 10 月 19 日
I have attached an image of some code I'm working through. I have pre-allocated two matrices but MATLAB is still displaying the message suggesting I pre-allocate. I'm trying to determine whether it shows this message regardless of whether I've already done what it's asking me to do or not. My assumption was this message would disappear once I pre-allocated but that's not been the case.
  1 件のコメント
James Tursa
James Tursa 2018 年 10 月 19 日
Please do not post code as images. Instead, post it as text and format it with the { } Code button.

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

採用された回答

Matt J
Matt J 2018 年 10 月 19 日
編集済み: Matt J 2018 年 10 月 19 日

It is true that you have pre-allocated, but (a) you still aren't using that pre-allocated space for anything, and (b) you are still using concatenation to make TBILL1Y grow with every pass through the loop. Your code should look something like,

count=0;
for i=...
 for j=...
       count=count+1;
       TBILL1Y(:,count)=DRAW(:,1);
   end
  end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by