• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 545
  • Last Modified:

Delimited Output With Matlab to Textfile

I have the following line of code:
dlmwrite('tempfile', exportData(i).array, '-append', 'delimiter', '\t', 'precision', 6);
to export a dataset to a text file delimited by tabs. The issue I am running into is when opening this in notepad (which is how it has to be done) the third column of data runs into the first when the third column's value becomes a very small number as an example the output in notepad looks like this:
another example:
with no tab and I need it to look like:
0.00237519 2504.5
8.5675e-005 5249.5
0.00237519     2504.5
8.5675e-005    5249.5
Does anybody know how to do this keeping the precision level at 6 and still ensuring there is a tab in between?

  • 3
1 Solution
Try to add dlmwrite(...,  'newline', 'pc')

Do you run this under Windows or Linux? How the file looks if you open it in another, not Notepad? For example, MATLAB editor?
Will it work if you use comma as a delimiter?
kpurchaseAuthor Commented:
It looks fine with wordpad, and cannot use comma delimitation unfortunately. Do I add the newline aspect at the end of the dlmwrite statement? And this is run on Windows.
Yes, add newline as a parameter pair:
dlmwrite('tempfile', exportData(i).array, '-append', 'delimiter', '\t', 'precision', 6, 'newline','pc');

You don't have to use comma, just try it to see that delimiter is inserted correctly.

However, if you see the data correctly in Wordpad, it means that delimiter is inserted. It's Notepad doesn't show the file correctly, may be because of wrong newline character.  

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now