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

조회 수: 15 (최근 30일)
sharad
sharad 2015년 2월 25일
답변: ag 2025년 1월 30일
How I can plot surface countour plot and velocity plot on same garph using MATLAB

답변 (1개)

ag
ag 2025년 1월 30일
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 CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by