Help me to convert 3d matrix (consider x-y-z plane) to x times 2d matrix (y-z). Then I want to write this output to a file as ...(x1y1z1), (x2y2z2),(x3y3z3) and so on; (xyz)=value of x-y-z position in matrix

댓글 수: 5

Walter Roberson
Walter Roberson 2016년 10월 19일
If you have position YourMatrix(J, K, L) where the three indices are not all the same, then where should that go into the output file?
Should the output order be YourMatrix(1, 1, :) then YourMatrix(1, 2, :) ... YourMatrix(1, end, :), YourMatrix(2, 1, :), YourMatrix(2, 2, :), ... and so on?
lafnath p
lafnath p 2016년 10월 19일
Actually I want to write the 3D array into a file in such a format :first write the 1st X-plane value then 2nd X-plane and so on..(data1,data2,(complete 1st X-plane) then in next line data1,data2(2nd X-plane..)and so on..)
Walter Roberson
Walter Roberson 2016년 10월 19일
Should the output order be YourMatrix(1, :, 1) then YourMatrix(1, :, 2) ... YourMatrix(1, :, end), YourMatrix(2, :, 1), YourMatrix(2, :, 2), ... and so on?
Should the output order be YourMatrix(:, 1, 1) then YourMatrix(:, 1, 2) ... YourMatrix(:, end, 1), YourMatrix(:, 2, 1), YourMatrix(:, 2, 2), ... and so on?
Should the output order be YourMatrix(:, 1, 1) then YourMatrix(:, 2, 1) ... YourMatrix(:, end, 1), YourMatrix(:, 1, 2), YourMatrix(:, 2, 2), ... and so on?
Steven Lord
Steven Lord 2016년 10월 19일
To ask a more specific version of Walter's question:
A = reshape(1:24, [2 3 4])
If you were to write A to a file in the way you want to write your real 3-D array, what would the EXACT contents of the file be? Be specific: I want to see exactly how you'd arrange the numbers 1 through 24 in the file and I would like to see whatever else you add beyond just the numbers in A.
lafnath p
lafnath p 2016년 10월 20일
편집: lafnath p 2016년 10월 20일
If X-,Y-,Z-axis is 2, 3, 4 respectively then .I need to write the matrix as:
g(1,1,1),g(1,2,1),g(1,3,1),g(1,1,2),g(1,2,2),g(1,3,2),g(1,1,3),g(1,2,3),g(1,3,3),g(1,1,4),g(1,2,4),g(1,3,4) nextline(Complete one xplane) g(2,1,1),g(2,2,1),g(2,3,1),g(2,1,2),g(2,2,2),g(2,3,2),g(2,1,3),g(2,2,3),g(2,3,3),g(2,1,4),g(2,2,4),g(2,3,4) nextline(2nd xplane..and so on...)
But in actual case x-y-z is very large .

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

답변 (1개)

Walter Roberson
Walter Roberson 2016년 10월 20일

0 개 추천

ps = size(g,2)*size(g,3)
fmt = [repmat('%g,', 1, ps-1), '%g\n'];
fprintf(fmt, permute(g, [2 3 1]));

카테고리

도움말 센터File Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

태그

질문:

2016년 10월 19일

답변:

2016년 10월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by