Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Can we use escape in display?
Date: Tue, 14 Jul 2009 19:01:04 +0000 (UTC)
Organization: UMN
Lines: 19
Message-ID: <h3iklg$nnr$1@fred.mathworks.com>
References: <h3icin$5n5$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1247598064 24315 172.30.248.35 (14 Jul 2009 19:01:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 14 Jul 2009 19:01:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 870237
Xref: news.mathworks.com comp.soft-sys.matlab:555450


Another alternative is to input the actual new line characters.

>> disp(['Hello' char(13) 'World'])
Hello
World

If you're building a string to write to file you'll have to decide whether you want to do Windows or Unix new lines.  

% Windows
fid = fopen('Test.txt','w+');
S = ['Hello' char(13) char(10) 'World'];
fwrite(fid,S);
fclose(fid);

% Unix
fid = fopen('Test.txt','w+');
S = ['Hello' char(10) 'World'];
fwrite(fid,S);
fclose(fid);