Plotting problem & Does the matlab can plot raster map?

I have coordinates (X,Y) and its corresponding value (Z), How to visualize them and distinguish with different color for each point? Just like a raster file that every pixel has a value in it.
Thank you very much!

2 件のコメント

KSSV
KSSV 2019 年 6 月 4 日
編集済み: KSSV 2019 年 6 月 4 日
It is not a raster data. These are scattered points.
ZC Song
ZC Song 2019 年 6 月 4 日
So could you give me a hint that how to transfer those data to raster format?

サインインしてコメントする。

 採用された回答

KSSV
KSSV 2019 年 6 月 4 日
編集済み: KSSV 2019 年 6 月 4 日

1 投票

Let X,Y,Z be your m*3 data.
x = unique(X) ; nx = length(x) ;
y = unique(X) ; ny = length(y) ;
X = reshape(X,nx,ny) ;
Y = reshape(Y,nx,ny) ;
Z = reshape(Z,nx,ny) ;
figure
pcolor(X,Y,Z)
shading interp
figure
surf(X,Y,Z)
shading interp

9 件のコメント

ZC Song
ZC Song 2019 年 6 月 4 日
Thank you very much for your reply!
It seems there is some error:
QQ截图20190603232341.png
Now I attached the data file named "ans" which contains X,Y,Z data.
ZC Song
ZC Song 2019 年 6 月 4 日
QQ截图20190603232341.png
KSSV
KSSV 2019 年 6 月 4 日
Huumh...attach your data. Or else try this:
m = 500 ; n = 500 ;
x = linspace(min(X),max(X),m) ;
y = linspace(min(Y),max(Y),n) ;
[XX,YY] = meshgrid(x,y) ;
ZZ = griddata(X,Y,Z,XX,YY) ;
pcolor(XX,YY,ZZ)
shading interp
KSSV
KSSV 2019 年 6 月 4 日
To display use:
scatter(X,Y,100,Z,'s','filled')
ZC Song
ZC Song 2019 年 6 月 4 日
Thanks for your patience. I've uploaded the data name 'ans.mat'
ZC Song
ZC Song 2019 年 6 月 4 日
編集済み: ZC Song 2019 年 6 月 4 日
My final goal is this:
I have a DEM map, and from my simulation I can get a .asc file data. Now I transform the .asc data to geoference gird data. As you can see in the attachment.
I want to superpose them together.
Like this:
QQ截图20190603234402.png
ZC Song
ZC Song 2019 年 6 月 4 日
Thanks for your help I think I'm close to the goal! One question is how to only display one color? like yellow?
QQ截图20190603235619.png
Next step would be superpose this map to the .raster map or a .tiff map
KSSV
KSSV 2019 年 6 月 4 日
YOu have only two values in Z 0 and 1. You can plot them like below:
scatter(X(Z==1),Y(Z==1),'s','filled','r')
hold on
scatter(X(Z==0),Y(Z==0),'s','filled','b')
ZC Song
ZC Song 2019 年 6 月 4 日
Great! it works!
Thank you very much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

タグ

質問済み:

2019 年 6 月 4 日

コメント済み:

2019 年 6 月 4 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by