how to plot contours in matlab

3 ビュー (過去 30 日間)
Muhammad Usman Saleem
Muhammad Usman Saleem 2016 年 6 月 7 日
回答済み: KSSV 2016 年 6 月 8 日
I would like to make contours of elevations. My text file which contain lat, lon and elevation data set. I want to genterate contours of this elevation data set.on this help vedio and documentations i able to prepare this code as starting
a=load('2002dec.txt');
>> x=a(:,1);
y=a(:,2);
>> z=a(:,3);
>> [x,y]=meshgrid(60:0.5:78,21:0.5:38);
>> contour(x,y,z)
But getting error.
I also want to set a shape file as back ground of these contours.Any guide line will be highly appriciable.
My text file data and shape file has been attached with this post

採用された回答

KSSV
KSSV 2016 年 6 月 7 日
編集済み: KSSV 2016 年 6 月 7 日
shapefile = 'PAK_adm1.shp' ;
S = shaperead(shapefile) ;
data = importdata('2002dec.txt') ;
x = data(:,1) ; x = unique(x) ;
y = data(:,2) ; y = unique(y) ;
z = data(:,3) ;
[X,Y] = meshgrid(x,y) ;
Z = reshape(z,size(X)) ;
pcolor(Y,X,Z) ; shading interp ;
hold on
for i = 1:length(S)
plot(S(i).X,S(i).Y,'k') ;
  2 件のコメント
Muhammad Usman Saleem
Muhammad Usman Saleem 2016 年 6 月 7 日
編集済み: Muhammad Usman Saleem 2016 年 6 月 7 日
Dear @Dr. Siva Srinivas Kolukula , what this code is doing? It is only producing color image consist on grids. Please tell me what kind of map it is? Whether these are another view to show contours?
Tell me please whether it is DEM?
KSSV
KSSV 2016 年 6 月 7 日
I mentioned already....use contour(Y,X,Z)....you will get the contours...

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

その他の回答 (2 件)

KSSV
KSSV 2016 年 6 月 7 日
You may use contour(Y,X,Z) for plotting contour....

KSSV
KSSV 2016 年 6 月 8 日
Try using freezeColors after hold on..... You may get the funciton from the link: http://in.mathworks.com/matlabcentral/fileexchange/7943-freezecolors---unfreezecolors

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by