Creating a standard deviation contour plot
9 次查看(过去 30 天)
显示 更早的评论
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)')
2 个评论
Image Analyst
2020-5-4
I think people are waiting for you to attach 'B00001.txt' with the paper clip icon. Because I can't tell what you did - no picture attached, etc. and I can't run your code. I don't see any call to contour() or contourf(). I don't see why you're using pcolor() instead of imshow(). I think pcolor() display images but I never use it because it doesn't display the last row or column. So I've given up (for now). I might check back later, after you've had time to read this:
采纳的回答
Walter Roberson
2020-5-4
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');
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Contour Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!