Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Coding Questions 6. (5 points) Consider a MATLAB row vector that represents the

ID: 3757063 • Letter: C

Question

Coding Questions 6. (5 points) Consider a MATLAB row vector that represents the values of a mathematical concept of a vector in N dimensional space. The distance of that vector from the origin is given mathematically as .x , where x, is the ith component of vector x. Encode a MATLAB function called computeDistance that computes that distance where x is represented in MATLAB as a row vector. 7. (5 points) The following MATLAB code fragment is expressed using the linspace function. Write a MATLAB function yFunc that uses the colon operator to compute the same value - y - linspace(1,10,10) 8. (10 points) A vector is a palindrome if it is the same from left to right as it is from right to left. Encode a function named makePal that takes a row vector and makes it a palindrome. For example, given the vector x [123 41, makePal(x) would return [1 2343 2 1]. (5 points] Encode a MATLAB fragment that generates a column vector of 10 logarithmically spaced points between the values 0 and 99 inclusive. 9. 10.(5 points) Encode MATLAB function called minMaxMean that takes a row vector as an argument and returns three values. The minimum value of any element in the vector, the max element and the mean value of the vector Do not use any MATLAB built in functions in your answer.

Explanation / Answer

function d = dist(a) //Function prototype

d=0; //Variable initialization for d
for elm = a //For loop for iterating over the distance
d = d+elm*elm; //Calculating all the sum of d^2
end

d = sqrt(d); //Taking the square root of sum of all the distances.

end

As per Chegg policy we are supposed to do only the first question.