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.
Augustus
Peter Boettcher wrote:
>
>
> "Augustus Vogel" <avogel@xxxxxxxxxxxxx> writes:
>
>> Hello,
>> I am using Matlab to make some calculations of some data and
then
> am
>> writing an .m file to export the results in text format so they
> can
>> be used in another program. This other program unfortunately,
is
>> very picky with its input files. When I open the text file that
I
>> have written in Wordpad (or text edit for Mac) it looks fine.
But
> in
>> Notepad, an newline command (\n or \r) isn't recognized and
gives
> a
>> box, thus ruining the format of the text file.
>>
>> The basic code looks something like this:
>> fid=fopen('test.txt','at')
>> fprintf('wish this would work')
>> fprintf('\rit would make me happy')
>> fclose(fid)
>>
>> Any suggestions on how I can get data to be written to new
lines
>> without the apparent unrecognized formatting for notepad?
>
> fopen(file, 'wt') or 'at' as you've written is correct. Once you
> do
> 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
> out
> there that convert line ending types for different platforms.
>
> Or if your goal is eventually a Windows program, then you can
> probably
> 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/>
>
.
- References:
- unwanted formatting of saved text file
- From: Augustus Vogel
- Re: unwanted formatting of saved text file
- From: Peter Boettcher
- unwanted formatting of saved text file
- 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
- Index(es):
Relevant Pages
|