フィルターのクリア

draw matrix H with “contourf”

3 ビュー (過去 30 日間)
Raphael Biendarra
Raphael Biendarra 2021 年 4 月 6 日
回答済み: prabhat kumar sharma 2024 年 2 月 22 日
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
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
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:
I hope it helps!

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by