writematrix with tab delimiter inconsistently producing delimiters
16 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Christian Taylor
il 5 Ago 2024
Risposto: Star Strider
il 5 Ago 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 Commenti
Risposta accettata
Star Strider
il 5 Ago 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Spreadsheets in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!