How can I create a loop for this equation?
Show older comments
function [level] = initiallevel(t,dem)
total = sum(dem(1:t));
level = total/t;
end
I need to then create a vector that consists of [L4 all the way to L12] so made up of 9 rows and 1 column.
>> L4 = initiallevel(4,demand);
>> L5 = initiallevel(5,demand);
>> L6 = initiallevel(6,demand);
>> L7 = initiallevel(7,demand);
>> L8 = initiallevel(8,demand);
>> L9 = initiallevel(9,demand);
>> L10 = initiallevel(10,demand);
>> L11 = initiallevel(11,demand);
>> L12 = initiallevel(12,demand);
Accepted Answer
More Answers (1)
Torsten
on 4 Jul 2019
1 vote
L = cumsum(demand);
L = L./(1:numel(L));
L = L(4:12)
Categories
Find more on Loops and Conditional Statements 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!