How to plot 4D contourf for the matrix C(40*40) with respect to A(40*40) as x axis and B(40*40) as y axis for different levels z=1000, 800, 600, 400 in one plot?

1 次查看(过去 30 天)
Dear Sir I have three matrices A,B and C having same size 40*40. I want to plot a contour of C(40*40) taking A(40*40) as x axis and B(40*40) as y axis for different levels z=1000, 800, 600, 400 in one plot. Please help.

采纳的回答

Walter Roberson
Walter Roberson 2015-9-19
If your X and Y data are sorted in a good grid, then
contourf(X, Y, C, [400, 600, 800, 1000])
If your X and Y are not sortable to a good grid then you will need to do some grid interpolation and contour that.
  11 个评论
Walter Roberson
Walter Roberson 2015-9-21
This was tricky to figure out.
I have enclosed a file patchfill.m which can be used for this purpose. This is for HG1 (Handle Graphics 1) only in its present form (I do not have an HG2 version to experiment with.) Beware: R2014b and later (HG2) represent contours a different way!
[~, h] = contour3(X1, Y1, C1);
hold on
patchfill(h, 400);
[~, h] = contour3(X2, Y2, C2);
patchfill(h, 600);
[~, h] = contour3(X3, Y3, C3);
patchfill(h, 800);
[~, h] = contour3(X4, Y4, C4);
patchfill(h, 1000);
The patchfill routine I provide does two things:
  1. alters the patch() properties returned by contour3 to allow the contours to fill. The contours returned by contour3 (in HG1) are deliberately configured to make it hard to turn on filling.
  2. sets the Z values to the value passed in, if one is passed in.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Contour Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by