reshaping data to fit contour plot requirements
7 次查看(过去 30 天)
显示 更早的评论
Hello All,
I have data in x,y,z format where x is 30:70, y is 15:45 (both unit spacing), and with one z point per x,y pair. Each is a 1271x1 vector. plot3 and stem3 work just fine with that format.
contour is different and, while I can create a meshgrid for x and y, I am not quite getting how to reshape z to fit the requirements of the routine. Future datasets will have different sizes so I'm trying to get a good understanding of what contour requires versus hardwiring something for this specific case.
I'm sure that this is covered somewhere but I can't find it in the Matlab docs, this forum's archives, or the Usenet.
Pointers to an M to RTF greatly appreciated.
0 个评论
采纳的回答
Akiva Gordon
2012-11-15
This strongly depends on how the data in "z" is stored. If the first 31 values in "z" represent the values for x = 30 & y = 15:45, and the next 31 values in "z" correspond to x = 31 & y = 15:45, etc., then it seems to me that you would likely get the result you are looking for by trying the following (assuming z is defined in the workspace):
x = 30:70;
y = 15:45;
[X,Y] = meshgrid(x,y);
Z = reshape(z,numel(y),numel(x));
contour(X,Y,Z)
If the data in "z" is stored differently, it would be helpful if you described how it is stored there.
0 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Distribution Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!