How I can plot surface countour plot and velocity plot on same garph using MATLAB
3 ビュー (過去 30 日間)
古いコメントを表示
How I can plot surface countour plot and velocity plot on same garph using MATLAB
0 件のコメント
回答 (1 件)
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!
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!