MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply TodayAssume that you have taken data across the surface of a sample, for example sheet resistance. The data is stored in a Nx3 matrix, where the columns are: [X,Y,data]. Assume that the lower-left corner of the sample is (X,Y) = (0,0), and the upper right corner of the sample is (X,Y) = (3,3), and the data is taken only at integers between 0:3 (4x4 or max of 16 locations across the sample).

The goal is to find the simplest way to take the data and construct a 2-dimensional matrix, where the data at (0,0) is in the lower-left and the data at (3,3) is in the upper right. Any locations with no data specified should end up as NaN in the final matrix. If any location is listed twice in the data, the LAST value (the one with the highest row index) should be used. It is possible that there is no data (i.e. data = []);

For example, if the input data is:

data = [ 0 0 5 1 1 2 2 2 7 3 3 8 1 1 6 ];

Then the output should be:

output = [ NaN NaN NaN 8 NaN NaN 7 NaN NaN 6 NaN NaN 5 NaN NaN NaN ];

31 correct solutions
22 incorrect solutions

Last solution submitted on May 16, 2013