Store results from for loop

조회 수: 2 (최근 30일)
civs
civs 2014년 8월 5일
댓글: civs 2014년 8월 7일
How can I store the results from every iteration in a for loop?

답변 (2개)

Azzi Abdelmalek
Azzi Abdelmalek 2014년 8월 5일
  댓글 수: 14
civs
civs 2014년 8월 7일
Oh ok, I didn't know both matrices (prices and weights) had to be of the same size for element wise multiplication.
I have modified the code a bit... I will attach it here.
civs
civs 2014년 8월 7일
Ok guys, so here is the code (sorry! it took me long to post because I made more changes). It takes quite a long time to run though. Anyway my question is...
how can I store the values of V_min_var, V_eff_var, V_min_ES, V_eff_ES without overwriting the results of the loop?
Thanks!

댓글을 달려면 로그인하십시오.


Iain
Iain 2014년 8월 7일
what you want to do is to store your output like this:
for i = 1:X
...
result_V_min_var(i) = V_min_var;
V_eff_var_list(i) = V_eff_var_list;
... etc
end
Whatever you use as the loop number, needs to NOT change within the loop.
  댓글 수: 4
civs
civs 2014년 8월 7일
I am not sure I fully understand this code. What I want is to store all the portfolio values from the loop so wherever I store it will be a vector of portfolio values. So I have 4 vectors in the end, one for each portfolio.
civs
civs 2014년 8월 7일
is the below a vector of portfolio values?
list_of_values(i) = new_value; % this is a list of ALL the values.
I attached the code. Line 59-62 those are the vectors I am referring to, these are supposed to be column vectors. I am not sure if this will work though...
The idea is to store all the values at every iteration.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Financial Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by