writematrix with tab delimiter inconsistently producing delimiters
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Christian Taylor
le 5 Août 2024
Réponse apportée : Star Strider
le 5 Août 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 commentaires
Réponse acceptée
Star Strider
le 5 Août 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!