"Error using year. Use DATE." typically occurs when you are trying to extract the year from an invalid date. This error occurs because MATLAB's year function can only be applied on a datetime or a duration. So, make sure you are passing a datetime object to year function.
For example:
main.m107 chars4 lines
This code will display the current year. If you still get the error, check the date format being passed to datetime function.
gistlibby LogSnag