简体   繁体   English

Matlab-2D浓度/轮廓图

[英]Matlab - 2D concentration/contour plot

2D matlab Contour plot - concentration map 2D Matlab等高线图-浓度图

I have two sets of data 我有两组数据

x = (x1, x2, x3....) y = (y1, y2, y3....) x =(x1,x2,x3 ....)y =(y1,y2,y3 ....)

which describe the cartesian co-ordinates of a set of points in the plane. 描述了平面中一组点的笛卡尔坐标。 So x1y1 is the coordinate of object 1 and so on. 因此x1y1是对象1的坐标,依此类推。

The coordinates are restricted to certain values: a minimum (0) and maximum value which describe the dimensions of the plane (which is a rectangle). 坐标被限制为某些值:描述平面(矩形)尺寸的最小值(0)和最大值。

For example, the coordinates might describe the position of objects in a room, or trees in a field or so on. 例如,坐标可以描述对象在房间中的位置,或在田野中的树木等的位置。

How can I represent these co-ordinates (the two sets of data) as a 2D contour/concentration plot using matlab? 如何使用Matlab将这些坐标(两组数据)表示为2D轮廓/浓度图? ie rather than just dots on the plane (a scatter graph) a smooth continuous colour map/ 即,不仅是平面上的点(散布图),还包括平滑的连续颜色图/

kind regards W 亲切的问候W

It is not really obvious what you are asking. 您要问的不是很明显。 Remember for making a contour you need another set of data besides x and y. 请记住,要绘制轮廓,除了x和y之外,还需要另一组数据。

I think what you are trying to achieve can be done using meshgrid which gives you a proper mesh on your data: 我认为您可以尝试达到的目的可以使用meshgrid来完成,它可以为您的数据提供适当的网格:

x = rand(1,20);
y = rand(1,20);
[X,Y]=meshgrid(x,y);
Z = zeros(size(X));
mesh(X,Y,Z);

在此处输入图片说明

Generate a matrix where every value is a coordinate region and add 1 for every point in that region. 生成一个矩阵,其中每个值都是一个坐标区域,并对该区域中的每个点加1。

So for example you have points (0.5,0.7) (0.9,0.8) (1.5,0.6) (1.8,1.2) 例如,您有(0.5,0.7)(0.9,0.8)(1.5,0.6)(1.8,1.2)点

And you map this to a matrix where every value corresponds to a "square" of a value region 1x1. 然后将其映射到一个矩阵,其中每个值都对应一个值区域1x1的“平方”。

a(1,1) = everything in the region 0 <= x < 1, 0 <= y < 1
a(1,2) = everything in the region 0 <= x < 1, 1 <= y < 2
a(2,1) = everything in the region 1 <= x < 2, 0 <= y < 1
a(2,2) = everything in the region 1 <= x < 2, 1 <= y < 2

So you would get [2 1;0 1] and then you can contour it. 因此,您将得到[2 1;0 1] ,然后可以对其轮廓化。

If you need a finer resolution just decrease the mapping size. 如果需要更好的分辨率,只需减小映射大小即可。

I can't give you a code solution on the fly because my Matlab is a bit rusty, but the principle should work fine. 我无法即时为您提供代码解决方案,因为我的Matlab有点生锈,但是原理应该可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM