Extracting X and Y binary data to simple X Y file
조회 수: 1 (최근 30일)
이전 댓글 표시
I am trying to extraxt X and Y coordinates form a binary file.
I want to generate a text file X and Y cordinates in every itteration.
I tried this code:
delete shape_*.dat;
for i=1:numel(SX)
%sx1 = SX{i};
%sy1 = SY{i};
filename = sprintf('shape_0%d.dat', i);
%dlmwrite(filename,SX{i})
dlmwrite(filename,{SX{i},SY{i}},'Delimiter','\t')
end
Attached how it looks like SX and SY.
So the code generete something like that:
SX{i} SY{i}
Which means it put all the values of SX{i} then all the values of SY{i}.
but i want for example, the first colum of SX{1,1} be with the first colum of SY{1,1} and so one.
And save the file for every i.
댓글 수: 2
dpb
2021년 7월 16일
We can do nothing with images -- attach a short section of the input file and then explain clearly what it is you expect.
SX = readArray('sx.afdat');
SY = readArray('sy.afdat');
and those plus your attached results don't seem to have anything at all to do with a 'binary' file -- that would appear to be an ordinary text file...what's up with "binary"?
채택된 답변
Walter Roberson
2021년 7월 16일
vals = permute( cat(3, SX{K}, SY{K}), [1 3 2]);
vals is now a something-by-2-by-something array; in particular, 117 x 2 x 90. The first column is X and the second column is corresponding Y. The hyperplanes correspond to the x 90
It is not obvious to me how you want to represent pairs of columns for a 2D array. Perhaps you want to continue on to
vals = reshape(vals, size(vals,1), []);
That would give you 117 x 180 with alternating columns being X and Y.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Text Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!