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!