MATLAB: Using fprintf for .txt file

fprintffscanftxt

Hi All,
I'm having a bit a trouble trying to figure out this problem using fprintf to create a .txt input file to some analysis software I am using. This software suite is very particular with the format of this text file and I beleieve I have everything correct. The problem is that the sofware will not read the file, unless I open the text file after creating it with fprintf and press save. No additions to the file are made, and the date modified does not change either… Any thoughts?
Thanks, Marc

Best Answer

What program are you opening it with? (I assume MATLAB, but it could also be Word, Notepad, Wordpad, etc). I've had experiences where a given editing program might change the format when you save it, and also been down this rabbit hole where the slight variations of "just a text file" started to matter.
I'd suggest getting a text editor that can show all the formatting characters and look at the files using that. I'm a Vim fan, but emacs and a host of others can do it, too. Look at the before and after and you might be able to get what it's expecting at the end of the file.
You should also take a look at the tool you are using for comparing and make sure you make the comparisons very strict. A lot of comparison/diff tools ignore things like carriage returns and whitespace and concentrate on the actual content, but offer options to turn on this checking if you need it.
Good luck!