Run simulation 1000 times
显示 更早的评论
This code I made is a simulation that finds the the total profit(yearprofit) from trading a product
Q= 240 + 9*randn(250,1);
for k = 1:length(Q)
if Q(k) < 240
buy = Q(k)*100 + 150;
elseif Q(k) > 245
sell = Q(k)*100 - 150;
buy = 0;
elseif buy > 0
P(k) = sell - buy;
yearprofit = sum(P);
end
end
This finds the profit for 1 year, how do I make the simulation run 1000 times giving me 1000 different values to resemble 1000 years? Do I have to use another for-loop around it?
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Transaction Cost Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!