How can I graph pressure data as a contour?

18 views (last 30 days)
Tyler Couser
Tyler Couser on 27 Nov 2018
Answered: Akira Agata on 28 Nov 2018
I am trying to graph pressure coefficients at various locations on the roof of a house. I have the x and y locations stored in two separate vectors and then I have a third vector that stores the pressure coefficients. I was wondering if it was possible to create a 2D-contour plot of these pressures at their corresponding locations on the roof, or, if there is a plot that would be easier to use, but get similar results.
Here are some sample vectors:
x = [9.22; .22; .22; .22; .22; 2.22; 2.22; 2.22; 2.22; 2.22; 4.22; 4.22;...
4.22; 4.22; 4.22; 6.22; 6.22; 6.22; 6.22; 6.22; 8.22; 8.22; 8.22;...
8.22; 8.22; 8.22; 8.22; 8.22; 8.22; 8.22; 8.22; 8.22; .22; .22;...
1.22; 1.22; 2.22; 2.22; 3.22; 3.22; 4.22; 4.22; 5.22; 5.22; 6.22;...
6.22; 7.22; 7.22; 8.22; 8.22; 9.22; 9.22; 9.22; 9.22; 9.22; 9.22;...
9.22; 9.22; 9.22; 9.22; 9.22; 9.22; 9.22];
y = [13.27; 10.2; 7.65; 5.1; 2.55; 10.2; 7.65; 5.10; 2.55; 0; 10.2;...
7.65; 5.1; 2.55; 0; 10.2; 7.65; 5.1; 2.55; 0; 12.27; 11.27; 10.27;...
9.27; 8.27; 7.27; 6.27; 5.27; 4.27; 3.27; 2.27; 1.27; 13.27; 12.27;...
13.27; 12.27; 13.27; 12.27; 13.27; 12.27; 13.27; 12.27; 13.27;...
12.27; 13.27; 12.27; 13.27; 12.27; 13.27; 0; 12.27; 11.27; 10.27;...
9.27; 8.27; 7.27; 6.27; 5.27; 4.27; 3.27; 2.27; 1.27; 0];
pressure = [0.0002; 0.0003; 0.0007; 0.0007; 0.0007; 0.0003; 0.0009;...
0.0007; 0.0007; 0.0006; 0.0003; 0.0005; 0.0003; 0.0002; 0.0004;...
-0.0013; 0.0001; 0.0001; 0.0004; 0.0001; 0.0002; 0.0000; 0.0001;...
0.0001; -0.0001; 0.0001; 0.0002; 0.0002; 0.0001; 0.0006; 0.0002;...
0.0002; 0.0004; 0.0007; 0.0004; 0.0003; 0.0002; 0.0002; 0.0002;...
0.0003; 0.0001; 0.0003; -0.0000; 0.0001; 0.0003; 0.0002; 0.0001;...
0.0004; 0.0003; 0.0004; 0.0001; 0.0001; 0.0002; 0.0001; 0.0001;...
0.0001; 0.0003; 0.0002; 0.0003; 0.0002; 0.0002; 0.0001; 0.0003]

Answers (1)

Akira Agata
Akira Agata on 28 Nov 2018
Please convert your data into "grid data" using meshgrid and griddata functions, like:
% Make x-y mesh grid
[xq,yq] = meshgrid(...
linspace(min(x),max(x),40),...
linspace(min(y),max(y),40));
% Interpolate using "griddata" function
pq = griddata(x,y,pressure,xq,yq,'cubic');
% Visualize the result
figure
contour(xq,yq,pq)
xlabel('x','FontSize',16)
ylabel('y','FontSize',16)
c = colorbar;
c.Label.String = 'Pressure';
c.Label.FontSize = 16;
pressure.png

Community Treasure Hunt

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

Start Hunting!