draw matrix H with “contourf”
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
pranay dattani
am 6 Apr. 2021
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])
Antworten (1)
prabhat kumar sharma
am 22 Feb. 2024
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!
0 Kommentare
Siehe auch
Kategorien
Mehr zu Discrete Data Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!