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

Write a simple MATLAB function to complete the following task: The function incl

ID: 3797175 • Letter: W

Question

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 midDotp0 returns the dot product of the two vectors. Write a simple MATLAB script to complete the following task: Write a sequence of steps to: a) Fill the vector C with numbers 1 to 10 in ascending order. b) Fill the vector D with the numbers I to 10 in descending order, e) Use the function midDotp0 and vectors C and D to compute the dot product. c) Print the result.

Explanation / Answer

To define the function you will have to define it in the following syntax:-

function t = midDotp(x,y)
if ~isvector(x) && ~isvector(y)
error('Input must be vector')
end
t=dot(x,y);

it checks if both the inputs are vectors or no and if they are it takes the dot product.

To define the vectors

c=[1:10];

d=[10:1];

both in ascending descending order and then call the declared function

r= midDotp(c,d);

disp('Dot product='); disp(r);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote