Extracting X and Y binary data to simple X Y file
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Tesla
am 16 Jul. 2021
Bearbeitet: Tesla
am 16 Jul. 2021
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 Kommentare
dpb
am 16 Jul. 2021
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"?
Akzeptierte Antwort
Walter Roberson
am 16 Jul. 2021
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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Text Files finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!