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

Create a script file with a name that properly identify the assignment and yours

ID: 3620536 • Letter: C

Question

Create a script file with a name that properly identify the assignment and yourself. For the first homework, the file name should be Hw01_0123456.n if your student ID number is 0123456. Make sure that at the top of file you insert your name and student ID number in the form of comments. Do the problems here by writing programming statements in this single script file. Each problem must be in an individual cell so that it can be executed separately from the others. Make sure that your program runs with no errors. Report your results, findings, observations and interpretations as comments at the end of the programming statements for each of the problems. Submit your script file on BladdKNird; any other forms of submission (e.g. email) will not be accepted. Randomly generate a large number, nPts, of points in n dimensions with components each lying between -1 and 1. Randomly generate another such vector to be the target vector. Find among the vectors that you have generated the one lying closest to the target vector. Recall that the distance between any given two n-dimensional vectors a and b: can be computed by the formula You need to display the minimum distance between the chosen vector and the target, the components of the chosen vector, and the components of the target vector. For this problem you may set nPts = 10000 and n = 5. but your program should work under rather general circumstances.

Explanation / Answer

A=[4 6 8]       //A is the one vector

A =

     4     6     8

>> B= [2 3 4] // B is the one vector

B =

     2     3     4

>> C=A-B        //subtraction of A, B vectors

C =

     2     3     4

>> C_squared=C.^2        //square of A,B vectors

C_squared =

     4     9    16

>> C_sum=sum(C_squared) //Sum of C vector

C_sum =

    29

>> sqrt(C_sum)   squareroot of C_sum

ans =

    5.3852 This is the minimum distance of the chosen vector

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