How I can plot surface countour plot and velocity plot on same garph using MATLAB

3 ビュー (過去 30 日間)
sharad
sharad 2015 年 2 月 25 日
回答済み: ag 2025 年 1 月 30 日 2:56
How I can plot surface countour plot and velocity plot on same garph using MATLAB

回答 (1 件)

ag
ag 2025 年 1 月 30 日 2:56
Hi Sharad,
This can be achieved by using the "hold" feature of MATLAB. The below code demonstrates how to do the same:
% Generate example data for the surface
[X, Y] = meshgrid(-2:0.1:2, -2:0.1:2);
Z = X .* exp(-X.^2 - Y.^2);
% Generate example data for the velocity field
[U, V] = gradient(Z);
% Create the contour plot
figure;
contourf(X, Y, Z, 20); % 20 specifies the number of contour levels
colormap(jet); % Select a colormap
colorbar; % Display the colorbar
hold on; % Retain current plots to add more
% Overlay the velocity field
quiver(X, Y, U, V, 'k'); % 'k' denotes black arrows
% Add labels and a title
xlabel('X-axis');
ylabel('Y-axis');
title('Surface Contour Plot with Velocity Field');
% Adjust axis limits if necessary
axis tight;
hold off;
For more details, please refer to the following MathWorks documentation: https://www.mathworks.com/help/matlab/ref/hold.html
Hope this helps!

カテゴリ

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