writematrix with tab delimiter inconsistently producing delimiters
6 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Star Strider
2024-8-5
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!