How to make a counter?
Show older comments
Hi, i'm trying to set up a counter such that after 3 days stocks will be replenished whenever the available stocks falls below 5. How do I do that?
%Preallocate the vector.
Available_Stock = zeros(1,31);
Available_Stock(1)=20;
for i= 1:numel(Available_Stock-1)
Available_Stock(i+1) = Available_Stock(i) - Stock_Sold(i);
%Intepretation: We do not have to add in new stocks as long as ordering amount is above 5.
if Available_Stock(i) > 5
Available_Stock(i+1) = Available_Stock(i) - Stock_Sold(i);
%Intepretation: Once ordering amount is at or below 5, we need to place an order.
else
while(Available_Stock(i) < 5 || Available_Stock(i) == 5)
counter = 0;
counter = counter +1;
2 Comments
Image Analyst
on 10 Oct 2014
What is (the badly-named) i? Is that the day number?
Stephen23
on 10 Oct 2014
Answers (0)
Categories
Find more on Student's t Distribution 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!