How to plot contour?
조회 수: 14 (최근 30일)
이전 댓글 표시
Can anyone help me to suggest a coding to plot pressure contour for this pressure values.
x = [-4.2195;
-5.7195;
-7.2195;
-8.7195;
-2.7195;
-4.2195;
-5.7195;
-7.2195;
-8.7195;
-1.2195;
-2.7195;
-4.2195;
-5.7195;
-7.2195;
-8.7195];
y = [6.3;
6.3;
6.3;
6.3;
4;
4;
4;
4;
4;
1.7;
1.7;
1.7;
1.7;
1.7;
1.7];
pressure = [0.007102637;
0.006237111;
0.003838996;
0.003957271;
0.010614624;
0.005477081;
0.004232522;
0.004189709;
0.003693549;
0.008519338;
0.005573828;
0.003937382;
0.004821263;
0.004177716;
0.004030966];
댓글 수: 0
답변 (3개)
Voss
2022년 6월 2일
x = [-4.2195;
-5.7195;
-7.2195;
-8.7195;
-2.7195;
-4.2195;
-5.7195;
-7.2195;
-8.7195;
-1.2195;
-2.7195;
-4.2195;
-5.7195;
-7.2195;
-8.7195];
y = [6.3;
6.3;
6.3;
6.3;
4;
4;
4;
4;
4;
1.7;
1.7;
1.7;
1.7;
1.7;
1.7];
pressure = [0.007102637;
0.006237111;
0.003838996;
0.003957271;
0.010614624;
0.005477081;
0.004232522;
0.004189709;
0.003693549;
0.008519338;
0.005573828;
0.003937382;
0.004821263;
0.004177716;
0.004030966];
I = scatteredInterpolant(x,y,pressure);
[X,Y] = meshgrid(unique(x),unique(y));
contour(X,Y,I(X,Y))
colorbar()
댓글 수: 0
Star Strider
2022년 6월 2일
% Make x-y mesh grid
x = [-4.2195;
-5.7195;
-7.2195;
-8.7195;
-2.7195;
-4.2195;
-5.7195;
-7.2195;
-8.7195;
-1.2195;
-2.7195;
-4.2195;
-5.7195;
-7.2195;
-8.7195];
y = [6.3;
6.3;
6.3;
6.3;
4;
4;
4;
4;
4;
1.7;
1.7;
1.7;
1.7;
1.7;
1.7];
pressure = [0.007102637;
0.006237111;
0.003838996;
0.003957271;
0.010614624;
0.005477081;
0.004232522;
0.004189709;
0.003693549;
0.008519338;
0.005573828;
0.003937382;
0.004821263;
0.004177716;
0.004030966];
[xq,yq] = meshgrid(...
linspace(min(x),max(x),170),...
linspace(min(y),max(y),170));
% Interpolate using "griddata" function
pq = griddata(x,y,pressure,xq,yq,'cubic');
% Visualize the result
figure
hsc = surfc(xq,yq,pq, 'EdgeColor','none');
hold on
[~,hc3] = contour3(xq,yq,pq, 10, '-k', 'ShowText','on'); % Draw 10 Contours ('ShowText' Is Optional)
Lvls = hc3.LevelList;
hsc(2).LevelList = Lvls; % Match The 'surfc' Contours With The 'contour3' Contours
hold off
xlabel('x','FontSize',16)
ylabel('y','FontSize',16)
c = colorbar;
c.Label.String = 'Cp';
c.Label.FontSize = 16;
c.Limits = [0 0.011];
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

