Extracting X and Y binary data to simple X Y file

1 visualización (últimos 30 días)
Tesla
Tesla el 16 de Jul. de 2021
Editada: Tesla el 16 de Jul. de 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 comentarios
dpb
dpb el 16 de Jul. de 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"?
Tesla
Tesla el 16 de Jul. de 2021
The input files are very large,
But the images are showing indeed what containe the input file (SX and SX).
You can see that SX and SX are like matrixes size (1003x1) with cells of dimensions (117x90).
I just want to have a file with X Y coordinates for every step
for example:
881.395017137202 191.319844359188 392.188873596697 271.034002421179
881.240268490015 191.966052698394 392.614416558883 271.540473556606
881.097198679310 192.614050849855 392.985303204938 272.087729560085
It looks like
X1_1 Y1_1 X1_2 Y1_2
X2_1 Y2_1 X2_2 Y2_2
X3_1 Y3_1 X3_2 Y3_2

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 16 de Jul. de 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.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by