How to plot contour?

15 ビュー (過去 30 日間)
Seelan Kumar
Seelan Kumar 2022 年 6 月 2 日
回答済み: Star Strider 2022 年 6 月 2 日
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];

回答 (3 件)

Voss
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()

Walter Roberson
Walter Roberson 2022 年 6 月 2 日
look in the File Exchange for scattered contour

Star Strider
Star Strider 2022 年 6 月 2 日
Another option would be contour3
% 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];

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by