How to populate 2D array from 2 vectors perpendicular to each other?
이전 댓글 표시
I have 2 files. Each file contains 4 columns. Column 1, 2 and 3 define the location of a point in x, y, and z-axis respectively, on a Cartesan coordinate. Column 4 is the Value of that point. 'Inline' and 'Crossline' are perpendicular to each other and intersect at (0,0) coordinate. How do I populate a 2D array from these 2 files? (The data below are simplified. The real data has finer resolution)
Inline =
2.800000 0 15.0000 1.3678
1.000000 0 15.0000 1.2000
0 0 15.0000 1.0000
-1.000000 0 15.0000 1.2000
-2.500000 0 15.0000 1.5688
Crossline =
0 -2.300000 15.0000 1.3546
0 -1.000000 15.0000 1.1000
0 0 15.0000 1.0000
0 1.000000 15.0000 1.1500
0 2.700000 15.0000 1.3558
댓글 수: 7
Matt J
2013년 1월 9일
Populate it based on what rule?
Yun Inn
2013년 1월 9일
Matt J
2013년 1월 10일
Show the expected output given the simplified example data you gave above.
Walter Roberson
2013년 1월 10일
The sample matrices do not represent vectors.
Yun Inn
2013년 1월 10일
Walter Roberson
2013년 1월 10일
Each of those groups is "V-shaped"; the inputs are not "two vectors perpendicular to each other".
Yun Inn
2013년 1월 10일
채택된 답변
추가 답변 (1개)
Walter Roberson
2013년 1월 10일
[a,b] = ndgrid(A(:,1), B(:,2));
c = bsxfun(@times, A(:,4), B(:,4).');
Output = [a(:), b(:), A(:,3)*ones(size(A,1)*size(B,1),1), c(:)];
댓글 수: 1
Andrei Bobrov
2013년 1월 10일
편집: Andrei Bobrov
2013년 1월 10일
[a,b,c] = ndgrid(A(:,1), B(:,2), A(:,3));
d = A(:,4)*(B(:,4).');
Output = [a(:), b(:), c(:), d(:)];
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!