this code is meant for importing 300 .txt files and summing and mean of all values of the files and plotting the final results. clear all clc;
% Generating 2D Meshgrid [X,Y] = meshgrid(185:8:849,169:8:625); %-------------------------------
% Importing all the 300 files
files = dir( 'imageset1_*.txt'); for i=1:numel(files) A{i} = dlmread( files(i).piv, '\t', 3 , 0 ); end
% Summation of X-components of the 300 files
Xsum =A(1)(:,3); for k = 2:299 Xsum=Xsum+A(k)(:,3); end
% Taking average of the X-components of the 300 files
Xavg = Xsum/299; %Xavg(isnan(Xavg)) = 0;
% Summation of Y-components of the 300 files
Ysum = A{1}(:,4); for m = 2:299 Ysum=Ysum+A{m}(:,4); end
%Taking average of the Y-components of the 300 files
Yavg = Ysum/299; %Yavg(isnan(Yavg)) = 0;
% Calculating the magnitude of the X-component and Y-component
Zavg = sqrt(Xavg.^2+Yavg.^2);
% Making the NaN Values Zero
Zavg(isnan(Zavg)) = 0;
% Creating a Dummy Matrix of 12 x 18
Zplot = rand(58,84); %--------------------------------------------------
% Assigning the Value of Zavg in the Dummy Matrix
for e = 1:4872 %------------------------------------------------------- Zplot(e)=Zavg(e); end
%*********************************************************************** % Creating a Dummy Matrix of 12 x 18
Xplot = rand(58,84); %--------------------------------------------------
% Assigning the Value of Zavg in the Dummy Matrix
for e = 1:4872 %------------------------------------------------------- Xplot(e)=Xavg(e); end
% Creating a Dummy Matrix of 12 x 18
Yplot = rand(58,84); %--------------------------------------------------
% Assigning the Value of Zavg in the Dummy Matrix
for e = 1:4872 %------------------------------------------------------- Yplot(e)=Yavg(e); end
%***********************************************************************
%Contour Plot figure; contour(X,Y,Zplot,100,'LineWidth',3,'Fill','on','clipping','off'); xlabel('\fontsize{20}X - Pixels'); ylabel('\fontsize{20}Y - Pixels'); title('\fontsize{22}CONTOUR PLOT'); colorbar; hold on; quiver(A{1}(:,1),A{1}(:,2),Xavg,Yavg,'color','black'); axis([200 800 100 700]);%%%%%%%%%%%%%% colormap('jet');
% Setting the minimum and the maximum limit of the colormap and colorbar on the contour plot caxis([0 10]);
% Overlapping the overlapped images with the velocity vectors
figure; load('matlab.mat'); imcropped_93=imcrop(imcell1_93,[195 182 631 434]); imshow(imcropped_93); hold on; quiver(A{1}(:,1)-195,A{1}(:,2)-182,Xavg,Yavg,'color','yellow');
hold on;