Question: Please solve the following problem in Matlab Homework Problem 2: Fun with Arrays Part A: Write a script file called padrv.m. At the start of

Please solve the following problem in Matlab

Please solve the following problem in Matlab Homework Problem 2: Fun with

Homework Problem 2: Fun with Arrays Part A: Write a script file called padrv.m. At the start of this file, you will create a row vector v, and define an integer n, where n is greater than the length of the vector v. Your code will insert zeros at the beginning of v so that the length becomes n. For example, if v and n are defined as follows: v= [1-4 2?4] and n = 8, then your code should calculate the new v to be [o o o 1-4 2 0 41. Part B: Write a script file called unpad.m, which creates a row vector, removes all zeros at the beginning of the vector, and returns the remaining elements of the vector (i.e., it drops the zeros at the beginning of the vector). Assume that at least one element in the array w is non-zero. For example, w= [0 0 0 1-4 2 0 4], then your code should calculate the new w to be [1-4 2 0 4]. An important case to check your code is that if your vector does not start with zeros, it should return the same vector. If w [1 -4 2 o 4], then your code should calculate the new w to be [1 -4 2 0 4]. For this problem you will turn in two files padrv.m and unpad.m

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!