Question: MATLAB ONLY. FOLLOW ALL DIRECTIONS ACCORDINGLY. Assignment (1)Write an m-file to calculate the dot product of two vectors with arbitrary dimension. The function should input

MATLAB ONLY. FOLLOW ALL DIRECTIONS ACCORDINGLY.

Assignment

(1)Write an m-file to calculate the dot product of two vectors with arbitrary

dimension. The function should input two vectors, u and v ,and output their dot product, d. Test your program with the vectors u=(1,2,3,4) and v=(2,4,6,8). Recall that the command dot(u,v) also calculates the dot product, so this is a good way to check that your program is working correctly. This test should be in the diary you turn in.

(2)Write an m-file to create an nn matrix with 110, 320, 530,..., 210n100 down the diagonal and zeros every where else. For example, for n = 3 the matrix would be A = 11000 03200 00530 .

The function should input matrix size, n, and output a matrix, A, as described above. Test your program with n=2 and n=5. These tests should be in the diary you turn in.

HW GUIDELINES

You should turn in both your completed code(the m-files), and a diary containing successful execution of each code (using the tests given in the

problems).Your grade will be based on correctness, completeness, organization, and neatness.

I suggest that you do not open the diary until after you have the code working.This way the diary has only the essentials in it. Or, you can copy

and paste your command window into a word/textfile.

Remember that m-files should be commented so thatthereaderknowswhat the program/function does. Include your name and section number on the top of the page.

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!