draw matrix H with “contourf”
3 ビュー (過去 30 日間)
古いコメントを表示
Hi, I want to plot the distribution of matrix H along a plane for the following time instances t=0,0.25,0.5,0.75,1 (5individual figures)
Size of matrix H: 51x19 double
I tried everything from the Mathwork side to draw this contourf plots but nothing worked.
Hope you guys can help me?
3 件のコメント
pranay dattani
2021 年 4 月 6 日
x = 0:0.25:0.5:0.75:1;
y = 1:101;
[X Y] = meshgrid(x, y);
G = X.*f(Y)+0.95*h(Y);
contour(G, [-5 -3 -1 -0.1 0 0.1 1 3 5])
回答 (1 件)
prabhat kumar sharma
2024 年 2 月 22 日
Hi Raphael,
I understand that you are trying to plot countour at different time instances.
To visualize the distribution of matrix H across various time points, MATLAB's contourf function is an excellent tool for generating filled contour plots. If H is structured as a three-dimensional matrix with the third dimension representing time.
Make sure to adjust the indexing of H(:,:,i) to match the structure of your matrix. If H is organized in a different way, or if you have distinct matrices for each time instance, the indexing will need to be modified to reflect your data's specific arrangement.
you can create individual figures for each specified time instance as follows:
% Assuming H is a 3D matrix of size 51x19x5, where the third dimension is time
% Time instances you want to plot
timeInstances = [0, 0.25, 0.5, 0.75, 1];
% Loop through each time instance
for i = 1:length(timeInstances)
% Select the slice of matrix H at the current time instance
% Assuming the timeInstances correspond to the indices of the third dimension of H
matrixSlice = H(:,:,i);
% Create a new figure
figure;
% Plot the filled contour plot of the matrix slice
contourf(matrixSlice);
% Add color bar to indicate the scale
colorbar;
% Add title and axis labels as needed
title(sprintf('Distribution of H at t=%.2f', timeInstances(i)));
xlabel('X-axis');
ylabel('Y-axis');
% Adjust additional plot settings as desired
end
Countour Plots:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1624238/image.png)
I hope it helps!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Contour Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!