Saving/Visualizing all loop results

1 回表示 (過去 30 日間)
Núria Bautista
Núria Bautista 2016 年 9 月 18 日
コメント済み: Núria Bautista 2016 年 9 月 18 日
Good morning,
I think my question must be quite simple but I don't find how to resolve it. I have a loop and I want to 'save' (or at least visualize) the results. The problem is with the code I only can 'save/see' the 'last' column, not all (not all the results of the iteration). Here's the code:
b = xlsread('Data.xls', 'Sheet1'); %here I'm reading the excel data
d= size(b); % the size of the input table is 8 x 16 columns.
cols= d(:,2);
Results=[]
for a=b(:,2:cols)
n= 2;
m2 = ar(a,n);
K=6;
hf2=forecast(m2,a,K);
for a=b(:,2:cols) % here I try to save the results but it only save the 'last column', not all the columns.
Results=[forecast(m2,a,K)]
end
end
What could be the problem?
Thanks in advance! :)

採用された回答

Mischa Kim
Mischa Kim 2016 年 9 月 18 日
I assume you intentionally have two for loops, correct?
Either way, in case you do not know the size of the final matrix you can simply append vectors:
Results = [Results forecast(m2,a,K)]
  1 件のコメント
Núria Bautista
Núria Bautista 2016 年 9 月 18 日
Thanks Mischa! I had a problem because I was repiting the iteration but now is solved! thanks a lot! :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by