Matlab Assignment Solution on User-defined Functions