How can I create a segmented contour plot?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Christine Lynch
le 30 Juil 2018
Commenté : Christine Lynch
le 31 Juil 2018
I solved a 1D moving boundary heat transfer problem and I want to recreate something like the graphs on the left in this image. Anyone know how I can do that?
2 commentaires
Réponse acceptée
jonas
le 31 Juil 2018
Modifié(e) : jonas
le 31 Juil 2018
Looks like you actually have a 2D data set but want to plot in 3D, which means you have to add an arbitrary 'depth'. This will give you a color-figure that is more difficult to interpret than a normal 2D-plot. Nevertheless, I've made a small example, with result attached.
%%Create data
x=0:180;
z=-sind(x);
figure;
subplot(1,3,1)
plot(x,z)
axis tight
%%Extrude to a width of 10 and plot
subplot(1,3,2)
y=1:10;
z2=repmat(z,numel(y),1);
contourf(x,y,z2)
subplot(1,3,3)
surf(x,y,z2,'edgecolor','none')
colorbar
Note: Surf and contourf will connect the data linearly. If you want a more correct shape of the temperature distribution, then you have to either solve for more points or apply another interpolation method prior to plotting (using e.g. meshgrid & griddata).
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Contour Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!