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 Comments

Wir wissen nicht was die intraday_price Variable ist.
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

Sign in to comment.

Answers (0)

Categories

Products

Release

R2020a

Asked:

on 13 Jul 2020

Edited:

on 13 Jul 2020

Community Treasure Hunt

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

Start Hunting!