In Matlab: How to create a 2d map from a 3 columns file
14 次查看(过去 30 天)
显示 更早的评论
Relatively new to Matlab, I've been tryin to create a 2d map from a 3 columns file (x coord, y coord, value of cell (x,y)) but not sure how to proceed.
For example:
1901 0 1
1901 -10 2
1901 -20 3
1902 0 -1
1902 -10 3.5
1902 -20 1.5
1903 0 5
1903 -10 -3
1903 -20 0
Thanks in advance for any help!
0 个评论
采纳的回答
KSSV
2020-7-14
data = [1901 0 1
1901 -10 2
1901 -20 3
1902 0 -1
1902 -10 3.5
1902 -20 1.5
1903 0 5
1903 -10 -3
1903 -20 0 ] ;
x = data(:,1) ; y = data(:,2) ; z = data(:,3) ;
nx = length(unique(x)) ;
ny = length(unique(y)) ;
X = reshape(x,[ny,nx]) ;
Y = reshape(y,[ny,nx]) ;
Z = reshape(z,[ny,nx]) ;
pcolor(X,Y,Z)
shading interp
colorbar
2 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!