Thread Subject: Can we use escape in display?

Subject: Can we use escape in display?

From: Arthur Zheng

Date: 14 Jul, 2009 16:43:03

Message: 1 of 5

I want to display a string.

using command: display('somestring\n');

and it shows on the screen that:
somestring\n

How could the newline escape '\n' be shown?

Subject: Can we use escape in display?

From: Nathan

Date: 14 Jul, 2009 17:26:43

Message: 2 of 5

On Jul 14, 9:43 am, "Arthur Zheng" <hzhe...@gatech.edu> wrote:
> I want to display a string.
>
> using command:   display('somestring\n');
>
> and it shows on the screen that:
> somestring\n
>
> How could the newline escape '\n' be shown?

how about:
temp = sprintf('somestring\n');
display(temp);


-Nathan

Subject: Can we use escape in display?

From: Jeremy Smith

Date: 14 Jul, 2009 19:01:04

Message: 3 of 5

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);

Subject: Can we use escape in display?

From: Rune Allnor

Date: 14 Jul, 2009 19:44:25

Message: 4 of 5

On 14 Jul, 21:01, "Jeremy Smith" <smit1...@umn.NOSPAM.edu> wrote:
> 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

... use FPRINTF.

Rune

Subject: Can we use escape in display?

From: Arthur Zheng

Date: 15 Jul, 2009 00:33:03

Message: 5 of 5

"Jeremy Smith" <smit1729@umn.NOSPAM.edu> wrote in message <h3iklg$nnr$1@fred.mathworks.com>...
> Another alternative is to input the actual new line characters.
>
> >> disp(['Hello' char(13) 'World'])
> Hello
> World

Thanks!

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
new line Jeremy Smith 14 Jul, 2009 15:04:10
display Arthur Zheng 14 Jul, 2009 12:44:07
rssFeed for this Thread

Contact us at files@mathworks.com