Re: unwanted formatting of saved text file



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/>
>
.



Relevant Pages

  • Re: quicker more efficient formatting macro needed
    ... identify changed fields (like your suggestion to flag changed tasks). ... Select the first row and color format those fields with changes ... Use Fill Down to color all change task rows ...
    (microsoft.public.project)
  • Re: Making a partition inactive ?
    ... The "Active" flag means no more that you CAN boot from ... And you can delete ALL from this secondary drive, or format it (the "Active" ... >>> OS installed on its first partition. ...
    (microsoft.public.windowsxp.general)
  • RE: conditional formatting color
    ... If Flag = 1 Then ... would like to conditional format the corresponding date on the calendar with ... Summary Formula Is = NOT)) ' ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Date and Time Picker - Removeing Drop Button?
    ... So the date and time picker shows times instead of dates. ... This is working fine with a custom format, ... I can't see what that flag does. ... That's the start time control. ...
    (microsoft.public.win32.programmer.ui)
  • [RESEND] [PATCH] x86: Allow MMCONFIG above 4GB on x86_64
    ... SGI UV will have MMCFG base addresses that are greater than 4GB. ... Resend #2: Create a flag, that is set by platform specific code, ...
    (Linux-Kernel)