Write a simple MATLAB function to complete the following tas

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.

Solution

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);

 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

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site