Re: unwanted formatting of saved text file
- From: "Augustus Vogel" <avogel@xxxxxxxxxxxxx>
- Date: Fri, 6 Jan 2006 12:08:31 -0500
Solved! Thanks for the help: I took out the 't' flag, and used \r\n
for each new line.
Peter Boettcher wrote:
> "Augustus Vogel" <avogel@xxxxxxxxxxxxx> writes:
>> I am using Matlab to make some calculations of some data and
>> writing an .m file to export the results in text format so they
>> be used in another program. This other program unfortunately,
>> very picky with its input files. When I open the text file that
>> have written in Wordpad (or text edit for Mac) it looks fine.
>> Notepad, an newline command (\n or \r) isn't recognized and
>> box, thus ruining the format of the text file.
>> The basic code looks something like this:
>> fprintf('wish this would work')
>> fprintf('\rit would make me happy')
>> Any suggestions on how I can get data to be written to new
>> without the apparent unrecognized formatting for notepad?
> fopen(file, 'wt') or 'at' as you've written is correct. Once you
> that, \n means newline, and you'll get the right characters for the
> platform you're on.
> If you generate the file on one platform and try to read it on
> another, you'll have problems no matter what. There are programs
> there that convert line ending types for different platforms.
> Or if your goal is eventually a Windows program, then you can
> force it manually if you leave out the 't' flag in fopen, and use
> '\r\n' (or \n\r, I forget).
> Peter Boettcher <boettcher@xxxxxxxxxx>
> MIT Lincoln Laboratory
> MATLAB FAQ: <http://www.mit.edu/~pwb/cssm/>
- Prev by Date: Re: Optimal network structure - pruning
- Next by Date: Re: coding for gnetic algorithm
- Previous by thread: Re: unwanted formatting of saved text file
- Next by thread: Nichols frequency response of LTI models