필터 지우기
필터 지우기

2D points to 3D Matrix

조회 수: 1 (최근 30일)
Juan Jurado
Juan Jurado 2011년 6월 20일
Hello, I have a set of 140 points in 2D (x,y coordinates) which when plotted form a quadrangle such as the one pictured here: http://imageshack.us/photo/my-images/43/207756bwnf8jcy.jpg/
The points are in no particular order. I'm trying to build a 3D matrix that will store these values in an order corresponding to how they are organized when plotted. For example, in that image, the points form a 10x14 grid of points. I'd like to build a 10x14x2 matrix out of those points where the (i,j,:) element of the matrix contains the x,y coordinates of the corresponding (i,j) point in the plot.
Any ideas?

답변 (1개)

Sean de Wolski
Sean de Wolski 2011년 6월 20일
So put them in order! Then do the work:
idx_sorted = sortrows(xypts,[1 2]); %sort them
ij = reshape(idx_sorted,[10 14 2]); %reshape them
  댓글 수: 2
Juan Jurado
Juan Jurado 2011년 6월 20일
Thanks for the quick reply! This doesn't seem to be working for me. I think it's because the relative spacing between points changes throughout the grid. Notice on the left half, the x-coordinates are linearly increasing from left to right, but after the second half, the x-coordinates are actually linearly increasing from left to right.
Juan Jurado
Juan Jurado 2011년 6월 20일
Maybe this image will clarify the problem and why sorting won't work:
http://imageshack.us/photo/my-images/195/image1qhe.jpg/

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by