Added error for-loop for task g) and error.m