%% txt file plotting close all % use calculate_scale to find the scale for the images, then input here amscale = 210.2/ 0.0254; %pix/in / m/in % scale for the professional images profscale = 224.9/ 0.0254; %pix/in / m/in %call datafromtxt and then convert from pixels to m by division %make sure to divide by the scale that matches with the images you put in %PIVlab to get the text files... % datafromtext exists at the bottom of this file % 5 different data sets professional = datafromtxt('prof', 9,';',1,'B')/profscale; amateur = datafromtxt('ours', 9,';',1, 'B')/amscale; oursPIV = datafromtxt('PIVlabours', 9, ',',3, 'B')/amscale; oursPIVwIP = datafromtxt('ourswIP', 9, ',',3, 'B')/amscale; largeOurs = datafromtxt('largeredo', 59, ',',3, 'largeredo_')/amscale; fps = 120; %define fps %convert from frames to sec: only for u and v (3 and 4) professional(1,:,3) = professional(1,:,3)*fps; professional(1,:,4) = professional(1,:,4)*fps; amateur(1,:,3) = amateur(1,:,3)*fps; amateur(1,:,4) = amateur(1,:,4)*fps; oursPIV(1,:,3) = oursPIV(1,:,3)*fps; oursPIV(1,:,4) = oursPIV(1,:,4)*fps; oursPIVwIP(1,:,3) = oursPIVwIP(1,:,3)*fps; oursPIVwIP(1,:,4) = oursPIVwIP(1,:,4)*fps; largeOurs(1,:,3) = largeOurs(1,:,3)*fps; largeOurs(1,:,4) = largeOurs(1,:,4)*fps; %adjust as needed for two datasets to line up %especially if camera pos changes or if comparing diff softwares professional(1,:,1) = professional(1,:,1)+.001; professional(1,:,2) = professional(1,:,2)*2; %professional(1,:,3) = professional(1,:,3)*2 amateur(1,:,1) = amateur(1,:,1)-.5*10^-4; amateur(1,:,2) = amateur(1,:,2)+.5*10^-4; %plot different datasets as desired figure quiver(professional(1,:, 1),professional(1,:, 2),professional(1,:, 3),professional(1,:, 4), 'r', 'LineWidth', 1.5, 'DisplayName', 'Professional') xlabel('X Location, meters','fontweight','bold', 'fontsize', 14) ylabel('Y Location, meters','fontweight','bold', 'fontsize', 14) title('Professional Vector field, LaVision') figure quiver(amateur(1,:, 1),amateur(1,:, 2),amateur(1,:, 3),amateur(1,:, 4), 'b', 'LineWidth', 1.5, 'DisplayName', 'Amateur') xlabel('X Location, meters','fontweight','bold', 'fontsize', 14) ylabel('Y Location, meters','fontweight','bold', 'fontsize', 14) title('Amateur Vector field, LaVision') figure quiver(amateur(1,:, 1),amateur(1,:, 2),amateur(1,:, 3),amateur(1,:, 4), 'b', 'LineWidth', 1.5, 'DisplayName', 'Amateur') hold on quiver(professional(1,:, 1),professional(1,:, 2),professional(1,:, 3),professional(1,:, 4), 'r', 'LineWidth', 1.5, 'DisplayName', 'Professional') xlabel('X Location, meters','fontweight','bold', 'fontsize', 14) ylabel('Y Location, meters','fontweight','bold', 'fontsize', 14) title('Vector plot comparison: Professional vs Amateur, both LaVision') legend('show', 'Location', 'SouthWest') figure quiver(oursPIV(1,:, 1),oursPIV(1,:, 2),oursPIV(1,:, 3),oursPIV(1,:, 4), 'c','LineWidth', 1.5) xlabel('X Location, meters','fontweight','bold', 'fontsize', 14) ylabel('Y Location, meters','fontweight','bold', 'fontsize', 14) title('Amateur Vector field, PIVlab') figure quiver(amateur(1,:, 1),amateur(1,:, 2),amateur(1,:, 3),amateur(1,:, 4), 'b', 'LineWidth', 1.5, 'DisplayName', 'LaVision') hold on quiver(oursPIV(1,:, 1),oursPIV(1,:, 2),oursPIV(1,:, 3),oursPIV(1,:, 4), 'c', 'LineWidth', 1.5, 'DisplayName', 'PIVlab') xlabel('X Location, meters','fontweight','bold', 'fontsize', 14) ylabel('Y Location, meters','fontweight','bold', 'fontsize', 14) title('Vector plot comparison: PIVlab vs LaVision') legend('show', 'Location', 'SouthWest') figure quiver(oursPIVwIP(1,:, 1),oursPIVwIP(1,:, 2),oursPIVwIP(1,:, 3),oursPIVwIP(1,:, 4), 'b', 'LineWidth', 1.5, 'DisplayName', 'PIVlab with image processing') hold on quiver(oursPIV(1,:, 1),oursPIV(1,:, 2),oursPIV(1,:, 3),oursPIV(1,:, 4), 'c', 'LineWidth', 1, 'DisplayName', 'PIVlab') xlabel('X Location, meters','fontweight','bold', 'fontsize', 14) ylabel('Y Location, meters','fontweight','bold', 'fontsize', 14) title('Vector plot comparison: PIVlab image processing vs none') legend('show', 'Location', 'SouthWest') figure quiver(largeOurs(1,:, 1),largeOurs(1,:, 2),largeOurs(1,:, 3),largeOurs(1,:, 4), 'b', 'LineWidth', 1.5, 'DisplayName', 'PIVlab 59 frames') hold on %quiver(oursPIV(1,:, 1),oursPIV(1,:, 2),oursPIV(1,:, 3),oursPIV(1,:, 4), 'c', 'LineWidth', 1.5, 'DisplayName', 'PIVlab') xlabel('X Location, meters','fontweight','bold', 'fontsize', 14) ylabel('Y Location, meters','fontweight','bold', 'fontsize', 14) title('Vector plot comparison: PIVlab large average vs small') legend('show', 'Location', 'SouthWest') %% do some matrix conversion--> save so mat represents plot %call reorganize function to save data in a matrix where the row and column %indices correspond to the x and y location of the vector % makes it so you can do a percent error calc between vectors at each % row,col location newUsPIV = reorganize(oursPIV); newUsLaVis = reorganize(amateur); %pass these 2 into percent error function errorMatrix = calcError(newUsPIV, newUsLaVis); %take the mean percent error xs = nanmean(errorMatrix,1); ys = nanmean(xs,2); ERROR_U = ys(1,1,1) ERROR_V = ys(1,1,2) function matByLoc = reorganize(A) sizeA = size(A); numpoints = sizeA(2); %get the min and max x locs of A minX = 4.2*10; maxX = 10*10; Xrange = (maxX-minX); %--> make it so tenths dig is int %get the min and max y locs of A minY = -4*10; maxY = 0; Yrange = (minY)*-1; newA = zeros(Xrange, Yrange, 2); %loop thru A and save in newA indices using a radix sort-type deal for i = 1:numpoints %get the first two digits of the x coord xcoord = A(1,i,1); xind = floor(xcoord*10^4); %floor will truncate! %get the first two digits of the y coord ycoord = A(1,i,2); yind = floor(ycoord*10^3); %floor will truncate! if xind>minX && xindminY && yind