MATLAB: Mean over time with a for loop

for loopmean

I'm new to Mathlab and have a problem doing something i consider should be simple. I have a dataset with a a column fyear (meaning fiscal year end) and an other column with associate dividend yield (DY). fyear goes for 2002 to 2012 and i want to create a loop doing the mean of DY for 2002 then 2003, then 2004 , … until it reach 2012. So basically and want the mean of DY for each year. There over 8000 DY per year.
Thank you

Best Answer

I found the answer i was looking. I use means = grpstats(variable you want to have the mean, variable based on)