how to plot a contour map using a matrix for X, Y and Z values?

3 次查看(过去 30 天)
M matrix is:
M = [0 5 10 15 20 25 30 35 40 45
5 0.0137945780000000 0.0140902780000000 0.0141900320000000 0.0142399090000000 0.0142897860000000 0.0143111620000000 0.0143289750000000 0.0143432260000000 0.0143503510000000
10 0.0211336350000000 0.0218034130000000 0.0220955500000000 0.0222238060000000 0.0223413730000000 0.0223983750000000 0.0224304390000000 0.0224731910000000 0.0224803160000000
15 0.0293099150000000 0.0304570880000000 0.0309416080000000 0.0311945560000000 0.0313833770000000 0.0314795680000000 0.0315330080000000 0.0315900100000000 0.0316113860000000
20 0.0383127290000000 0.0401261180000000 0.0408457730000000 0.0412590400000000 0.0415333640000000 0.0416723080000000 0.0417684990000000 0.0418468770000000 0.0418753790000000
25 0.0486978520000000 0.0512202070000000 0.0522711890000000 0.0528697140000000 0.0532758560000000 0.0534718020000000 0.0536249960000000 0.0537247500000000 0.0537746270000000
30 0.0601945210000000 0.0635255980000000 0.0649399690000000 0.0657807550000000 0.0663151520000000 0.0665859130000000 0.0667818590000000 0.0669172400000000 0.0669778050000000
35 0.0730877480000000 0.0774769320000000 0.0794007620000000 0.0804838080000000 0.0811927750000000 0.0815561650000000 0.0818411770000000 0.0819979340000000 0.0820976880000000
40 0.0854358900000000 0.0909188070000000 0.0933699100000000 0.0946987780000000 0.0955823150000000 0.0960347710000000 0.0963874740000000 0.0965834190000000 0.0967366130000000
45 0.0994477890000000 0.106052941000000 0.109099006000000 0.110823328000000 0.111820870000000 0.112383769000000 0.112818412000000 0.113057109000000 0.113228116000000];
How to plot a contour graph using the matrix M.. the first row and the first column of matrix M would be the coordinates for each value.. for example:
for the coordinates 5,5 the z value for the contour map would be 0.01379458 and for the coordinates 30,20 the z value would be 0.06578076. the idea is to plot all the coordinates of matrix M and use the z values for the contour plot.
What could be the best way to solve it?
  1 个评论
John D'Errico
John D'Errico 2018-3-18
编辑:John D'Errico 2018-3-18
Why not just call contour?
doc contour
Do you want to plot the surface, with iso-levels plotted as contour lines on the surface itself?

请先登录,再进行评论。

回答(1 个)

KSSV
KSSV 2018-3-18
x = M(1,2:end);
y = M(2:end,1);
[X,Y]=meshgrid(x,y);
Z=M(2:end,2:end) ;
Now use contour on X,Y and Z.

类别

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