How to plot a pcolor from 3 vectors?

68 ビュー (過去 30 日間)
Alex
Alex 2017 年 4 月 25 日
コメント済み: Alex 2017 年 4 月 26 日
I have 3 vectors that I imported from a text file in a three column format that I cannot change. The columns are latitude, longitude and temperature. I want to plot a 2D map with the temperature as a colorbar. Normally I use:
pcolor(lat,lon,temp), shading 'flat';%pcolor/mesh/surf(X,Y,Z)
But this only works when there is a value for every value of lat and lon; Z is a matrix. The values for lat and lon from my new source are scattered and at random intervals. Any suggestions, please?
Cheers,
Alex

回答 (1 件)

KSSV
KSSV 2017 年 4 月 26 日
doc griddata
N = 1000 ;
x = 2*rand(N,1) - 1;
y = 2*rand(N,1) - 1;
z = 2*rand(N,1) - 1;
v = x.^2 + y.^3 - z.^4;
%
d = -1:0.05:1;
[xq,yq,zq] = meshgrid(d,d,0);
% Interpolate the scattered data on the grid. Plot the results.
vq = griddata(x,y,z,v,xq,yq,zq);
plot3(x,y,v,'ro')
hold on
surf(xq,yq,vq)
  1 件のコメント
Alex
Alex 2017 年 4 月 26 日
Something is the matter with: vq = griddata(x,y,z,v,xq,yq,zq); ??? Error using ==> griddata at 53 XI and YI must be the same size or vectors of different orientations. I am guessing a ' is missing somewhere. For the moment, I am using:
pointsize = 10;
figure, scatter(data(:,1),data(:,2), pointsize, data(:,3))

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

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by