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

Matlab help!. My professor dosen\'t hardly explain anything in class so if you a

ID: 3005243 • Letter: M

Question

Matlab help!. My professor dosen't hardly explain anything in class so if you answer pls answer with explanations for the sytaxs you use.

A lot of different tasks require figuring out the shortest distance between one point and a set of other points. For example, you may want to find the store (or airport or gas station) that is closest to your current location. Or, if you are processing measurement data, you may want to figure out which historical data point the current measurement is closest to. In this project, you will write a Matlab function that determines that shortest distance between a test point and a set of given points in two dimensional space, and then use the function for several tasks. Here is what you need to do:

1. Write a Matlab function mindistance=findclosest(pointset,testpoint). For this function, the array pointset may have any number of rows, and has two columns; each row gives the location of a point in two-dimensions (in the plane). Meanwhile, the array testpoint has one row and two columns, which gives the location of a test point in two dimensions. Your Matlab function should return a scalar number, which is the minimum among the distances between testpoint and each point in pointset (where distance is calculated in the usual way using the Pythagorean theorem).

2. A square-shaped town has five gas stations which are located at its corners and also at very center. Specifically, the gas stations are located at the coordinates (0,0),(0,1),(1,0),(1,1), and (0.5,0.5). If your car is located at (0.2, 0.4), what is the distance to the closest gas station? Please use the findclosest function.

3. You are driving along a North-South road in this town. Specifically, the location of your car as you are driving along is (0.2, x), where x varies from 0 to 1. Please plot the distance to the closest gas station as a function of your location x along the road. Again, please use the findclosest function.

4. You are allergic to gas, so you want to live as far away from a gas station as possible. In this town, what’s the furthest away that you could be from the closest gas station? What location achieves this maximum distance from the nearest gas station? (Hint: for a whole bunch of test points, find the minimum distance to a gas station using findclosest; then maximize among these).

Explanation / Answer

Ans-

message xn is encoded by a codeword c(xn), whose interval J(x) is insideinterval I(xQn(xn) + 2n). This follows from dQlgPn1(xn)eQn(xn) + Pn(xnn(xn) 2L(xn)e2L(xn)+ 2(xn)< Qn).
Obviously a prex code is obtained, since a codeword can only be a prex of another
one, if their corresponding intervals overlap and the intervals J(xn) I(x) are obviously
disjoint for di erent n-s.Further, we mentioned already that arithmetic coding compresses down to the entropy
up to two bits. This is because for every sequence xn
it is L(xn) < lg1P+ 2. It can also be shown that the additional transmission of block length n or the introduction of the EOF symbol only results in a negligible loss of compression.
However, the basic algorithms we presented are not useful in order to compress longer
less since with increasing block length n the intervals are getting smaller and smaller.