Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Delete char(10) and char(13)?? and locate them in a matrix of cell?

Subject: Delete char(10) and char(13)?? and locate them in a matrix of cell?

From: Robin Chuang

Date: 25 Mar, 2013 09:52:14

Message: 1 of 3

Hi all
This is my first time posting on this central. :)
I am wondering how do you delete char(10) and char(13) in a cell??
I have a cell of [1x14 char] and it contains both char(10) and char(13).
I tried to use
r=strrep(s,char(10),'')
r=strrep(s,char(13),'')
however it turns out that I delete char 10 and char 13 appears and vise versa....

Also if would be nice if you know how to locate a cell contains char 10 or char 13 in a matrix of cell. (instead of checking one by one)....

Thanks a lot!!!

Subject: Delete char(10) and char(13)?? and locate them in a matrix of cell?

From: Bruno Luong

Date: 25 Mar, 2013 13:02:15

Message: 2 of 3

"Robbie Listener" wrote in message <kip6oe$i5q$1@newscl01ah.mathworks.com>...
> Hi all
> This is my first time posting on this central. :)
> I am wondering how do you delete char(10) and char(13) in a cell??
> I have a cell of [1x14 char] and it contains both char(10) and char(13).
> I tried to use
> r=strrep(s,char(10),'')
> r=strrep(s,char(13),'')
> however it turns out that I delete char 10 and char 13 appears and vise versa....

r=strrep(s,char(10),'')
r=strrep(r,char(13),'')

% Bruno

Subject: Delete char(10) and char(13)?? and locate them in a matrix of

From: dpb

Date: 25 Mar, 2013 14:18:51

Message: 3 of 3

On 3/25/2013 4:52 AM, Robin Chuang wrote:
> Hi all
> This is my first time posting on this central. :)
> I am wondering how do you delete char(10) and char(13) in a cell??
> I have a cell of [1x14 char] and it contains both char(10) and char(13).
> I tried to use r=strrep(s,char(10),'')
> r=strrep(s,char(13),'')
> however it turns out that I delete char 10 and char 13 appears and vise
> versa....
>
> Also if would be nice if you know how to locate a cell contains char 10
> or char 13 in a matrix of cell. (instead of checking one by one)....

Define a string for the \n characters--

nl=[char(13) char(10)];

Then you can use it to manipulate both characters at once such as

ix=findstr(findstr(c,nl)

and/or

strrep(c,nl,'')

--

Tags for this Thread

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.

Contact us