Please Matlab code!!!!!!!!!!!! Write a simple MATLAB function to complete the fo
ID: 3796695 • Letter: P
Question
Please Matlab code!!!!!!!!!!!!
Write a simple MATLAB function to complete the following task: The function includes three parameters: a vector C, a vector D, and n the number of elements in both vector C and D. The function called midDotp() returns the dot product of the two vectors. Write a simple MATLAB script to complete the following task: Write a sequence of steps to: Fill the vector C with numbers 1 to 10 in ascending order. Fill the vector D with the numbers 1 to 10 in descending order. Use the function midDotp() and vectors C and D to compute the dot product. Print the result.Explanation / Answer
Ans.
function result = midtop(C, D, n)
result = 0;
for i = 0:9
result += C[i] * D[i];
C = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
D = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1];
result = midtop(C, D, 10);
disp(result);