Creating a standard deviation contour plot
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Image Analyst
am 4 Mai 2020
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:
Akzeptierte Antwort
Walter Roberson
am 4 Mai 2020
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');
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Contour Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!