Matlab Sorting a Vector of data into a Matrix


hoku123
09-08-2010, 05:50 PM
Hi I am new here and would really appreciate some help solving this Matlab problem I am having.

I have a program that outputs a data file (specifically a .vec file) and I need help sorting the data into a matrix. The data is generated by analyzing a picture and creating a grid of points with each point having an X and Y coordinate and an X and Y velocity component. As a result each point in the picture has a resulting velocity vector at an angle.

I have utilized the quiver command in Matlab (quiver(X,Y,U,V)) which works fine, but it is difficult to see overall velocity trends. What I would like to do is to make a contour plot which plots the magnitude in color, and then plot the quiver on top of it for the directions.

My problem is that I cannot generate a matrix for the magnitude of the velocity in the contour plot.

So now the problem with interpreting the data. Like I mentioned, a grid is analyzed and has 5 data points, an X, and Y coordinate, the X and Y velocity component (refered to as U and V in the code) and a value of -1 or 1 which shows if the point analyzed is correct or incorrect. So the first thing I do in the code is to throw out all the points with a -1. This leaves me with a grid of with many missing points.

Now I need to come up with a matrix so that I can make a contour plot of the magnitude of the velocities. I have copied my short code and the .vec file below since I do not think I can attach files since I am new.

I apologize if this is in the wrong section or if this type of question is not allowed. Please move this post of that is the case. Any help would be much appreciated, I hope I have described my problem well enough for you all. Thanks in advance.

-Colin



clc;
clear all;
close all;


ALLDATA=importdata('Test Output.vec');


i=1;
while i<=size(ALLDATA.data,1)
if(ALLDATA.data(i,5)<0)
ALLDATA.data(i,:)=[];
else
i=i+1;
end
end


X=ALLDATA.data(:,1);
Y=ALLDATA.data(:,2);
U=ALLDATA.data(:,3);
V=ALLDATA.data(:,4);
CHC=ALLDATA.data(:,5);


Z = sqrt(U.^2 +V.^2)
contour(X,Y,Z)
hold on
quiver(X,Y,U,V)

hoku123
09-08-2010, 05:52 PM
Below is just a sample of the data points, I have thousands more.



TITLE="C:\Experiments7\Test 8-3-10 A\Test With Mew Particles\Analysis\Test With Mew Particles000000.T000.D000.P004.H001.L.vec" VARIABLES="X mm", "Y mm", "U m/s", "V m/s", "CHC", DATASETAUXDATA Application="PIV" DATASETAUXDATA SourceImageWidth="1600" DATASETAUXDATA SourceImageHeight="1200" DATASETAUXDATA MicrometersPerPixelX="773.960022" DATASETAUXDATA MicrometersPerPixelY="773.960022" DATASETAUXDATA LengthUnit="mm" DATASETAUXDATA OriginInImageX="799.000000" DATASETAUXDATA OriginInImageY="599.000000" DATASETAUXDATA MicrosecondsPerDeltaT="40000.000000" DATASETAUXDATA TimeUnit="ms" DATASETAUXDATA SecondaryPeakNumber="0" DATASETAUXDATA DewarpedImageSource="0" ZONE I=176, J=132, F=POINT
-611.428467, 456.636444, 0.023939, -0.017240, -1
-604.462830, 456.636444, 0.024907, 0.055842, -1
-597.497131, 456.636444, 0.046493, 0.061114, -1
-590.531494, 456.636444, -0.017830, -0.021462, -1
-583.565857, 456.636444, 0.001682, 0.019314, -1
-576.600220, 456.636444, 0.043993, 0.040280, -1
-569.634583, 456.636444, 0.014926, 0.023597, -1
-562.668945, 456.636444, -0.015231, 0.005794, -1
-555.703308, 456.636444, -0.011117, -0.081470, -1
-548.737671, 456.636444, 0.015206, -0.038341, -1
-541.772034, 456.636444, 0.019503, -0.009700, -1
-534.806396, 456.636444, -0.078914, 0.015786, -1
-527.840759, 456.636444, -0.079980, 0.020720, 1
-520.875122, 456.636444, 0.007604, -0.082636, -1
-513.909485, 456.636444, -0.004536, -0.075442, -1
-506.943848, 456.636444, -0.012813, 0.034104, -1
-499.978180, 456.636444, -0.003562, -0.001623, -1
-493.012543, 456.636444, 0.043702, 0.015424, -1
-486.046906, 456.636444, -0.024008, -0.022297, -1
-479.081268, 456.636444, -0.004682, -0.082736, -1
-472.115631, 456.636444, -0.008428, -0.078595, -1
-465.149994, 456.636444, 0.001560, -0.082031, -1
-458.184357, 456.636444, 0.004876, -0.079986, -1
-451.218719, 456.636444, 0.003431, 0.061482, -1
-444.253082, 456.636444, -0.000900, -0.038041, -1
-437.287445, 456.636444, 0.064967, -0.078074, -1
-430.321777, 456.636444, -0.059702, -0.033088, -1
-423.356140, 456.636444, 0.063010, -0.057600, -1
-416.390503, 456.636444, -0.014864, -0.018843, -1
-409.424866, 456.636444, -0.041108, 0.014268, -1
-402.459229, 456.636444, 0.039673, 0.013841, -1
-395.493591, 456.636444, -0.002064, -0.035640, -1
-388.527954, 456.636444, -0.001328, -0.035472, -1
-381.562317, 456.636444, -0.016291, 0.043803, -1
-374.596680, 456.636444, -0.017914, 0.040741, 1
-367.631012, 456.636444, 0.016681, 0.041725, -1
-360.665375, 456.636444, 0.034342, -0.054075, -1
-353.699738, 456.636444, -0.004496, -0.070667, -1
-346.734100, 456.636444, 0.004615, -0.067731, -1
-339.768463, 456.636444, -0.009803, -0.064599, -1
-332.802826, 456.636444, 0.045329, 0.035367, -1
-325.837189, 456.636444, -0.002650, -0.039843, -1
-318.871552, 456.636444, -0.001794, -0.071069, -1
-311.905914, 456.636444, -0.000889, -0.018279, -1
-304.940247, 456.636444, 0.016054, 0.038535, -1
-297.974609, 456.636444, 0.004880, -0.024207, -1
-291.008972, 456.636444, 0.001313, -0.024219, -1
-284.043335, 456.636444, -0.057707, -0.037176, -1
-277.077698, 456.636444, -0.057021, -0.041340, -1
-270.112061, 456.636444, 0.039620, -0.056557, -1
-263.146423, 456.636444, -0.022819, 0.005641, 1
-256.180786, 456.636444, 0.064580, 0.054961, -1
-249.215134, 456.636444, 0.033611, -0.058976, -1
-242.249496, 456.636444, -0.005540, -0.031746, -1
-235.283859, 456.636444, 0.005506, 0.027018, -1
-228.318222, 456.636444, -0.035419, -0.000031, -1
-221.352570, 456.636444, -0.038509, 0.008401, -1
-214.386932, 456.636444, 0.056635, -0.022710, -1
-207.421295, 456.636444, -0.047568, 0.050759, -1
-200.455658, 456.636444, 0.001977, -0.041417, -1
-193.490021, 456.636444, -0.074211, 0.002607, -1
-186.524368, 456.636444, -0.075020, -0.081390, -1
-179.558731, 456.636444, -0.058976, -0.034620, -1
-172.593094, 456.636444, -0.042700, 0.025526, -1
-165.627457, 456.636444, -0.082035, 0.023799, -1
-158.661804, 456.636444, -0.001096, -0.026550, -1
-151.696167, 456.636444, 0.001740, -0.035544, -1
-144.730530, 456.636444, 0.008636, -0.051067, -1
-137.764893, 456.636444, 0.063115, 0.020388, -1
-130.799255, 456.636444, -0.000556, -0.007989, -1
-123.833611, 456.636444, 0.013095, 0.043446, -1
-116.867966, 456.636444, -0.024906, 0.033029, -1
-109.902328, 456.636444, 0.055657, 0.022247, -1
-102.936684, 456.636444, 0.058853, 0.015791, -1
-95.971046, 456.636444, -0.008542, 0.006630, -1
-89.005409, 456.636444, -0.033476, 0.032981, -1
-82.039764, 456.636444, 0.027582, 0.022300, -1
-75.074127, 456.636444, -0.019058, -0.037232, -1
-68.108482, 456.636444, -0.079408, -0.023055, -1
-61.142845, 456.636444, 0.014538, -0.014225, -1
-54.177204, 456.636444, 0.008002, -0.034017, -1
-47.211563, 456.636444, -0.002139, -0.077190, -1
-40.245922, 456.636444, 0.016153, 0.028469, -1
-33.280281, 456.636444, 0.018054, 0.019272, -1
-26.314642, 456.636444, 0.056852, -0.080692, -1
-19.349001, 456.636444, 0.058393, -0.074238, -1
-12.383361, 456.636444, -0.038327, -0.017442, -1
-5.417720, 456.636444, 0.013539, -0.076838, -1
1.547920, 456.636444, 0.015108, -0.074484, -1
8.513560, 456.636444, -0.021069, 0.062701, -1
15.479201, 456.636444, -0.072368, -0.010804, -1
22.444841, 456.636444, -0.017844, -0.078342, -1
29.410482, 456.636444, -0.058363, 0.044256, -1
36.376122, 456.636444, -0.063770, 0.006873, -1
43.341763, 456.636444, 0.054194, 0.020448, -1
50.307404, 456.636444, 0.011844, -0.017453, -1
57.273045, 456.636444, 0.018776, -0.025906, -1
64.238686, 456.636444, -0.018983, 0.024979, -1
71.204323, 456.636444, -0.079865, -0.021411, 1
78.169968, 456.636444, 0.061957, -0.057591, -1
85.135605, 456.636444, -0.075135, -0.002578, -1
92.101250, 456.636444, -0.021435, -0.041789, -1
99.066887, 456.636444, -0.039098, -0.002210, -1
106.032524, 456.636444, -0.043466, -0.065123, -1
112.998169, 456.636444, -0.038852, -0.052133, -1
119.963806, 456.636444, -0.085611, -0.004951, -1
126.929451, 456.636444, -0.031017, -0.073863, -1
133.895096, 456.636444, 0.060235, -0.013247, -1
140.860733, 456.636444, 0.015058, 0.036593, -1
147.826370, 456.636444, 0.000888, -0.009109, -1
154.792007, 456.636444, -0.082562, -0.027457, -1
161.757645, 456.636444, -0.034359, -0.058411, -1
168.723297, 456.636444, 0.018368, -0.020263, -1
175.688934, 456.636444, 0.003610, 0.061117, -1
182.654572, 456.636444, -0.038111, -0.053869, -1
189.620209, 456.636444, -0.078420, -0.015769, -1
196.585861, 456.636444, -0.081308, -0.018193, -1
203.551498, 456.636444, 0.000178, 0.016065, -1
210.517136, 456.636444, -0.042298, -0.055491, -1
217.482773, 456.636444, 0.046200, -0.060022, -1
224.448410, 456.636444, 0.034040, 0.024239, -1
231.414063, 456.636444, 0.038660, -0.017040, -1
238.379700, 456.636444, 0.034583, -0.024881, -1
245.345337, 456.636444, -0.080895, -0.014858, -1
252.310974, 456.636444, -0.033832, 0.034145, -1
259.276611, 456.636444, -0.061268, 0.000797, -1
266.242249, 456.636444, -0.042475, -0.060102, -1
273.207886, 456.636444, -0.056389, 0.060876, -1
280.173553, 456.636444, 0.045931, -0.020129, -1
287.139191, 456.636444, -0.077392, 0.038385, -1
294.104828, 456.636444, -0.072913, -0.007800, -1
301.070465, 456.636444, -0.014870, -0.023994, -1
308.036102, 456.636444, -0.044626, 0.063674, -1
315.001740, 456.636444, -0.043038, -0.053967, -1
321.967377, 456.636444, -0.084418, -0.017556, -1
328.933014, 456.636444, -0.059268, 0.038531, -1
335.898651, 456.636444, -0.070791, -0.014489, -1
342.864319, 456.636444, -0.066711, -0.012527, -1
349.829956, 456.636444, 0.014421, 0.017430, -1
356.795593, 456.636444, -0.038449, 0.056739, -1
363.761230, 456.636444, -0.081149, -0.077935, -1
370.726868, 456.636444, -0.065653, 0.023706, -1
377.692505, 456.636444, 0.052354, -0.065347, -1
384.658142, 456.636444, -0.078980, -0.015902, 1
391.623779, 456.636444, -0.073813, -0.018410, -1
398.589417, 456.636444, 0.025375, -0.017348, -1
405.555054, 456.636444, -0.045050, 0.040658, -1
412.520721, 456.636444, -0.006209, 0.021493, -1
419.486359, 456.636444, 0.062630, -0.058163, -1
426.451996, 456.636444, 0.020335, -0.018575, -1
433.417633, 456.636444, -0.031158, -0.000228, -1
440.383270, 456.636444, -0.082564, -0.016690, -1
447.348907, 456.636444, -0.005781, -0.073617, -1
454.314545, 456.636444, -0.022055, 0.022028, -1
461.280182, 456.636444, 0.038439, 0.027214, -1
468.245819, 456.636444, 0.040604, 0.019078, -1
475.211487, 456.636444, -0.055271, -0.078779, -1
482.177124, 456.636444, -0.025622, 0.041877, -1
489.142761, 456.636444, -0.017430, 0.040645, -1
496.108398, 456.636444, -0.079612, -0.020648, -1
503.074036, 456.636444, -0.078225, -0.006478, -1
510.039673, 456.636444, 0.058356, 0.059446, -1
517.005310, 456.636444, -0.004206, -0.078136, -1
523.970947, 456.636444, -0.058652, 0.041079, -1
530.936584, 456.636444, 0.053881, 0.038749, -1
537.902222, 456.636444, -0.001543, 0.000090, 1
544.867859, 456.636444, -0.004220, -0.039587, -1
551.833496, 456.636444, -0.021439, 0.040971, -1
558.799133, 456.636444, 0.019452, 0.034478, -1
565.764771, 456.636444, -0.004785, -0.081640, -1
572.730469, 456.636444, -0.082415, -0.016892, -1
579.696106, 456.636444, -0.038581, -0.058053, -1
586.661743, 456.636444, -0.054628, -0.034804, -1
593.627380, 456.636444, -0.031657, -0.060016, -1
600.593018, 456.636444, -0.036641, -0.053780, -1
607.558655, 456.636444, -0.011603, -0.074699, -1
-611.428467, 449.670776, 0.020504, -0.018581, -1
-604.462830, 449.670776, -0.020805, -0.034925, -1
-597.497131, 449.670776, -0.063211, 0.053624, -1
-590.531494, 449.670776, -0.057192, 0.055856, 1
-583.565857, 449.670776, 0.057713, -0.061152, -1
-576.600220, 449.670776, 0.042946, -0.058969, -1
-569.634583, 449.670776, -0.044212, 0.057565, -1
-562.668945, 449.670776, -0.034392, 0.062056, -1

hoku123
09-09-2010, 04:31 PM
Does anyone have an idea? Maybe another forum that might be able to help me with this?