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 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