Question: Answer both questions in matlab (1) Write an m-file to calculate the dot product of two vectors with the same arbitrary dimension. The function should
(1) Write an m-file to calculate the dot product of two vectors with the same arbitrary dimension. The function should input two vectors, u and v, and output their dot product, d. Test your program with the vectors (1,2,3,4) and u = (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 and check should be in the diary you turn in (2) Write an m-file to create an n x n square matrix with 1, 3, 5,.. ,2n-1 down the diagonal and zeros everywhere else. For example, for n = 3 the matrix would be The function should input matrix size, n, and output a matrix, A, as de- scribed above. Test your program with n-5. This test should be in the diary you turn in HW GUIDELINES You should turn in a hard copy of both your completed code (the m-files), and a diary containing successful execution of each code (using the tests given in the problems) .You can edit and organize your document. The grade will be based on correctness, completeness, organization, and neatness. e Remember that m-files should be commented so that the reader knows what the program/function does. Include your name and section number on the top of first page
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
