how do I save the iterations of this loop in an array?

Hello,
I need to save each loop iteration in an array.
I tried everything I know, but obviouly thats not verry much.
here is my code:
x = 1000;
y = 1000;
fuellstand_o = zeros(1,1000);
fuellstand_oben = zeros(1,1000);
fuellstand_o(1) = 250000;
fuellstand_u = zeros(1,1000);
fuellstand_unten = zeros(1,1000);
fuellstand_u(1) = 150000;
fuellstand_risk = 50000;
kontostand = zeros(1,1000);
kontostand_1 = zeros(1,1000);
for k = 1:1000
if intraday_price(k) < 10 && fuellstand_u(k) > fuellstand_risk
fuellstand_o(k) = fuellstand_o + x;
fuellstand_u(k) = fuellstand_u - y;
kontostand(k) = kontostand(k) - intraday_price(k);
elseif intraday_price(k) > 40 && fuellstand_o(k) > fuellstand_risk
fuellstand_o(k) = fuellstand_o(k) - x;
fuellstand_u(k) = fuellstand_u(k) + y;
kontostand(k) = kontostand(k) + intraday_price(k);
end
if ((frequency(k) > 50) && (fuellstand_u(k) > fuellstand_risk) && (local_max(k) == 1))
fuellstand_o(k) = fuellstand_o(k) + x;
fuellstand_u(k) = fuellstand_u(k) - y;
kontostand(k) = kontostand(k) + 50;
end
if frequency(k) < 50 && fuellstand_o(k) > fuellstand_risk && local_min(k) == 1
fuellstand_o(k) = fuellstand_o(k) - x;
fuellstand_u(k) = fuellstand_u(k) + y;
kontostand(k) = kontostand(k) + 50;
end
end
fuellstand_oben(k) = fuellstand_o;
fuellstand_unten(k) = fuellstand_u;
kontostand_1(k) = kontostand;
I hope someone can help me...

댓글 수: 2

madhan ravi
madhan ravi 2020년 7월 13일
편집: madhan ravi 2020년 7월 13일
Wir wissen nicht was die intraday_price Variable ist.
Martin Tambour
Martin Tambour 2020년 7월 13일
편집: Martin Tambour 2020년 7월 13일
oh entschuldige, das sollte ich natürlich hizufügen
intraday_price und frequency sind beide ein 1x1000 vektor
und local_min und Local_max sind beide logical arrays

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

릴리스

R2020a

질문:

2020년 7월 13일

편집:

2020년 7월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by