writematrix with tab delimiter inconsistently producing delimiters
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Christian Taylor
el 5 de Ag. de 2024
Respondida: Star Strider
el 5 de Ag. de 2024
I'm writing a matrix to a .txt file using the following line of code:
writematrix(allCols,fullPath,'Delimiter','tab');
where allCols is a 53532x3 double. For some reason in the resulting .txt file, the tab delimiter is missing between the first and second columns for seemingly random rows and is instead replaced with a space. The only thing that seems to set the first column number in these rows apart is that the decimals end in 0, such that they only get written to 4 decimal places compared to the 5 that the other numbers are being written to. Is this a bug, or am I doing something wrong?
0 comentarios
Respuesta aceptada
Star Strider
el 5 de Ag. de 2024
It might be possible for you to verify whether the tab characters are ther or not using the funciton after creating the file.
Example —
format shortG
allCols = round(rand(8),5)
fullPath = 'test1.txt';
writematrix(allCols,fullPath,'Delimiter','tab');
A1 = readlines(fullPath)
This appears to diaplay the tab characters as '->' although there does not appear to be anything in the readlines documentation describing how the various delimiters are displayed.
Contrast this with —
fullPath = 'test2.txt';
writematrix(allCols,fullPath,'Delimiter','space');
A2 = readlines(fullPath)
.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!