% now I want to know the saving over time % that is why I need to record the 52 values of total_saving over the year total_saving(1) = 0; % iterate through all the 52 weeks in a year % but here I start with week 2? % 1st question: why? do I need to start from week 2? % 2nd question: what to fix so that first week's saving is counted too! for week=2:52 % rand() returns a random number between [0.0 .. 1.0] % multiply it with 25 to have [0.0 .. 25.0] range saving_this_week = rand() * 25; % accumulate the saving so far % see the way I reference last week saving using 'total_saving(week-1)'! total_saving(week) = total_saving(week-1) + saving_this_week; end % display the saving in y axis, by default x axis is 1 to 52. plot(total_saving);