MATLAB: Creating a standard deviation contour plot

contour plotMATLABpcolorstandard deviation

I am trying to create a contour plot from a matrix of standard deviation values. As you can see in the attached code I have matrixes of U and V. I want to take the standard deviation of each element of these matrixes and compile them into new matrixes of the same size for both U and V. I then plan to plot a contour plot of these standard deviation matrixes similarly to how I plotted U and V with pcolor.
The way I have it set up now does not seem to be outputting a matrix for pcolor to read for standard deviations. Is there anyway to accomplish this?
A=dlmread('B00001.txt', '',1,0); %Read first file
for k=2:100;
A=A+dlmread(['B00',sprintf('%03d.txt',k)], '',1,0); %Sum all Matrixes
end
A=A/100; %Average Matrixes
X = reshape(A(:,1),124,173); %Reshape all matrixes
Y = reshape(A(:,2),124,173);
U = reshape(A(:,3),124,173);
V = reshape(A(:,4),124,173);
AverageU=mean(nonzeros(U)) %Average Streamwise Velocity
AverageV=mean(nonzeros(V)) %Average Wall Velocity
stdU=std(U);
stdV=std(V);
pcolor(X,Y,U); %Contour Plot of Streamwise Velocities
hold on
shading interp
colormap(jet);
h = colorbar;
ylabel(h, 'm/s')
xlabel('x(mm)')
ylabel('y(mm)')
pause
pcolor(X,Y,V); %Contour plot of Wall Velocities
hold on
shading interp
colormap(jet);
h = colorbar;
ylabel(h, 'm/s')
xlabel('x(mm)')
ylabel('y(mm)')
pause
pcolor(X,Y,stdU); %Standard Deviation Contour plot of U
hold on
shading interp
colormap(jet);
h = colorbar;
ylabel(h, 'm/s')
xlabel('x(mm)','FontSize',100)
ylabel('y(mm)','FontSize',100)
pause
pcolor(X,Y,stdV); %Standard Deviation contour plot of V
hold on
shading interp
colormap(jet);
h = colorbar;
ylabel(h, 'm/s')
xlabel('x(mm)')
ylabel('y(mm)')

Best Answer

N = 100;
M = dlmread('B00001.txt', '',1,0); %Read first file
M(:,:,N) = 0; %preallocate
for k = 2:100;
M(:,:,k) = dlmread(['B00',sprintf('%03d.txt',k)], '',1,0); %read all Matrixes
end
A = sum(M, 3);
M_U = reshape(M(:,3,:), 124, 173, N);
M_V = reshape(M(:,4,:), 124, 173, N);
M_U_std = std(M_U, [], 3);
M_V_std = std(M_V, [], 3);
fig = figure();
subplot(fig, 1, 2, 1);
pcolor(M_U_std);
title('U std over all matrices');
subplot(fig, 1, 2, 2);
pcolor(M_V_std);
title('V std over all matrices');