how do I save the iterations of this loop in an array?
Show older comments
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
madhan ravi
on 13 Jul 2020
Edited: madhan ravi
on 13 Jul 2020
Wir wissen nicht was die intraday_price Variable ist.
Martin Tambour
on 13 Jul 2020
Edited: Martin Tambour
on 13 Jul 2020
Answers (0)
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!