Creating a standard deviation contour plot

9 ビュー (過去 30 日間)
rwn
rwn 2020 年 5 月 3 日
コメント済み: rwn 2020 年 5 月 4 日
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
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:
rwn
rwn 2020 年 5 月 4 日
To clear somethings up, I have 100 text files with different x,y coordinate values as well as U,V velocity values the code below turns these into a matrix and then averages all 100 matrixes into one matrix A. I have averaged the U and V values for other steps of my project. The pcolors are used because it is what a professor has reccomended to me. As you can see contour plots have already been established for X,Y,U and X,Y,V. I would like to create two more contour plots with the standard deviation values of U and V matrixes individual elements. So it will be something like pcolor(X,Y,stdU). I have put up the sample .txt file all 99 others are formatted the same. I have also uploaded a sample picture of the contour plot. Let me know if you still do not understand.

サインインしてコメントする。

採用された回答

Walter Roberson
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');
  1 件のコメント
rwn
rwn 2020 年 5 月 4 日
Thank you this helps very much.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by