M矩阵是:
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];
如何使用矩阵M绘制轮廓图..矩阵M的第一行和第一列将是每个值的坐标..例如:
对于坐标5,5,等高线图的z值为0.01379458,对于坐标30,20,z值为0.06578076。我们的想法是绘制矩阵M的所有坐标,并使用z值作为等高线图。
什么是最好的解决方法?
答案 0 :(得分:1)
要绘制3D轮廓,您可以使用contour3
。 x值由M(1,2:end)
给出。这意味着第一行,第2列直到结束。 y值M(2:end,1)
也是如此。 z是矩阵的其余部分:M(2:end,2:end)
。
完整代码:
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];
contour3(M(1,2:end),M(2:end,1),M(2:end,2:end))
结果
如果需要更多级别,可以指定第四个输入参数。例如
contour3(M(1,2:end),M(2:end,1),M(2:end,2:end),50)
给出