如何绘制一个3列矩阵彩色地图在MATLAB? [英] How to plot a 3-column matrix as a color map in MATLAB?

查看:901
本文介绍了如何绘制一个3列矩阵彩色地图在MATLAB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

予有含一组GPS坐标的温度值的矩阵。所以,我的矩阵如下所示:

I have a matrix containing the temperature value for a set of GPS coordinates. So my matrix looks like this :

Longitude  Latitude  Value
---------  --------  -----
12.345678  23.456789   25 
12.345679  23.456790   26
%should be :
%  x           y        z

等。

我想这个矩阵转换成一个人可视情节像彩色图(2D或3D),我该怎么办呢?

I want to convert this matrix into a human-viewable plot like a color plot (2D or 3D), how can I do this?

3D可以是这样的:

3D can be something like this :

或只是这个2-D版(看从顶部z轴)。

or just the 2-D version of this (looking from top z-axis).

我知道MATLAB具有冲浪功能,但我不知道如何使用它们。

I know MATLAB has surf and mesh functions but I cannot figure out how to use them.

如果我称之为

surf(matrix(:,1) , matrix(:,2) , matrix(:,3));

我得到的错误:

I get the error :

Error using surf (line 75)
Z must be a matrix, not a scalar or vector

在此先感谢您的帮助!

Thanks in advance for any help !

PS:这也将是巨大的,如果有一个功能是填补空白插值(平滑,无论:))。因为我有离散的数据,这将是更加美丽重新present它作为一个连续函数。

P.S : It would also be great if there is a function that "fills" the gaps by interpolation (smoothing, whatever :) ). Since I have discrete data, it would be more beautiful to represent it as a continous function.

PS 2:我也想用 plot_google_map 在z = 0的平面。

P.S 2 : I also want to use plot_google_map in the z=0 plane.

推荐答案

一个令人惊讶的难以找到答案。但我很幸运,别人已经问几乎同样的问题这里

A surprisingly hard-to-find answer. But I'm lucky that somebody else has asked almost the same question here.

我张贴的工作对我的回答:

I'm posting the answer that worked for me :

x = matrix(:,1);
y = matrix(:,2);
z = matrix(:,3);
  xi=linspace(min(x),max(x),30)
  yi=linspace(min(y),max(y),30)
  [XI YI]=meshgrid(xi,yi);
  ZI = griddata(x,y,z,XI,YI);
  contourf(XI,YI,ZI)

它打印一个漂亮的彩色地图。

which prints a nice color map.

这篇关于如何绘制一个3列矩阵彩色地图在MATLAB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆