Matlab Coding Homework

Please see the attachment for instructions, there are total two problems. Please save the script as answers.