Thread Subject: Convert imported xls to all strings

Subject: Convert imported xls to all strings

From: Joey

Date: 8 Sep, 2011 07:33:08

Message: 1 of 3

I'm importing an Excel sheet with a column that contains both strings as well as characters, e.g.

100
110
A10
A12

MATLAB is splitting these cells into num (100,110) and txt (A10,A12) variables. When selecting the column from the raw variable, I have a way to detect the entries that are numeric/doubles (iscellstr==false). How can I then convert these numeric/double entries into a char entry?

I've already tried num2str and then char, but num2str does not accept the entry. raw(1,1) gives an answer in the form ans = [100], which is apparently not a number (but a cell?). Any help?

Subject: Convert imported xls to all strings

From: Myron Flickner

Date: 10 Feb, 2012 17:38:11

Message: 2 of 3

"monnq" wrote in message <j49r3j$s9$1@newscl01ah.mathworks.com>...
> I'm importing an Excel sheet with a column that contains both strings as well as characters, e.g.
>
> 100
> 110
> A10
> A12
>
> MATLAB is splitting these cells into num (100,110) and txt (A10,A12) variables. When selecting the column from the raw variable, I have a way to detect the entries that are numeric/doubles (iscellstr==false). How can I then convert these numeric/double entries into a char entry?
>
> I've already tried num2str and then char, but num2str does not accept the entry. raw(1,1) gives an answer in the form ans = [100], which is apparently not a number (but a cell?). Any help?

I have the same problem - I'm importing an excel column with the names of brain regions - some are strings some are numbers. I need them to all be strings so i can create a map i.e. brain('V1'
) = xxx uiimport should have an option to convert numbers to strings. Is there a simple way around this ?

Subject: Convert imported xls to all strings

From: Steven_Lord

Date: 10 Feb, 2012 18:11:03

Message: 3 of 3



"Myron Flickner" <mdflickner@us.ibm.com> wrote in message
news:jh3km3$ocf$1@newscl01ah.mathworks.com...
> "monnq" wrote in message <j49r3j$s9$1@newscl01ah.mathworks.com>...
>> I'm importing an Excel sheet with a column that contains both strings as
>> well as characters, e.g.
>>
>> 100
>> 110
>> A10
>> A12
>>
>> MATLAB is splitting these cells into num (100,110) and txt (A10,A12)
>> variables. When selecting the column from the raw variable, I have a way
>> to detect the entries that are numeric/doubles (iscellstr==false). How
>> can I then convert these numeric/double entries into a char entry? I've
>> already tried num2str and then char, but num2str does not accept the
>> entry. raw(1,1) gives an answer in the form ans = [100], which is
>> apparently not a number (but a cell?). Any help?
>
> I have the same problem - I'm importing an excel column with the names of
> brain regions - some are strings some are numbers. I need them to all be
> strings so i can create a map i.e. brain('V1'
> ) = xxx uiimport should have an option to convert numbers to strings.
> Is there a simple way around this ?

Use CELLFUN to process raw. Have the function you specify as the function
CELLFUN will apply as one that converts numbers to strings and returns
strings unchanged.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

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.

rssFeed for this Thread

Contact us at files@mathworks.com