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:
read text and number Excel file

Subject: read text and number Excel file

From: A Ram

Date: 30 Sep, 2009 19:22:18

Message: 1 of 17

Hi,

Am trying to read in an Excel file that contains both text and numbers without
getting the text replaced by NaN.

I tried the following, but NON worked:

[num,str]=xlsread('filename.xls');

and

Name = xlsread('filename.xls');

Thanks !

Subject: read text and number Excel file

From: Feng

Date: 30 Sep, 2009 19:30:17

Message: 2 of 17

so what did you get?

"A Ram" <shal.hat@gmail.com> wrote in message <ha0b5a$3cu$1@fred.mathworks.com>...
> Hi,
>
> Am trying to read in an Excel file that contains both text and numbers without
> getting the text replaced by NaN.
>
> I tried the following, but NON worked:
>
> [num,str]=xlsread('filename.xls');
>
> and
>
> Name = xlsread('filename.xls');
>
> Thanks !

Subject: read text and number Excel file

From: dpb

Date: 30 Sep, 2009 19:39:28

Message: 3 of 17

A Ram wrote:
> Hi,
>
> Am trying to read in an Excel file that contains both text and numbers without
> getting the text replaced by NaN.
>
...

doc xlsread
>> ...
> Empty cells or cells with text create NaNs in the numeric result.
>
> Leading rows and columns of text do not create NaNs in the numeric
> result.
>> ...


You'll either have to replace the NaNs after importing or use another
technique afaik.

--

Subject: read text and number Excel file

From: A Ram

Date: 1 Oct, 2009 12:37:02

Message: 4 of 17

dpb <none@non.net> wrote in message <ha0ce7$fmb$1@news.eternal-september.org>...
> A Ram wrote:
> > Hi,
> >
> > Am trying to read in an Excel file that contains both text and numbers without
> > getting the text replaced by NaN.
> >
> ...
>
> doc xlsread
> >> ...
> > Empty cells or cells with text create NaNs in the numeric result.
> >
> > Leading rows and columns of text do not create NaNs in the numeric
> > result.
> >> ...
>
>
> You'll either have to replace the NaNs after importing or use another
> technique afaik.
>
> --



What other technique can I use? The two methods above replace the text with NaNs. How can I make matlab read/import the text also? Thanks

Subject: read text and number Excel file

From: Ashish Uthama

Date: 1 Oct, 2009 12:45:45

Message: 5 of 17

On Thu, 01 Oct 2009 08:37:02 -0400, A Ram <shal.hat@gmail.com> wrote:

> dpb <none@non.net> wrote in message
> <ha0ce7$fmb$1@news.eternal-september.org>...
>> A Ram wrote:
>> > Hi,
>> >
>> > Am trying to read in an Excel file that contains both text and
>> numbers without
>> > getting the text replaced by NaN.
>> >
>> ...
>>
>> doc xlsread
>> >> ...
>> > Empty cells or cells with text create NaNs in the numeric result.
>> >
>> > Leading rows and columns of text do not create NaNs in the numeric
>> > result.
>> >> ...
>>
>>
>> You'll either have to replace the NaNs after importing or use another
>> technique afaik.
>>
>> --
>
>
>
> What other technique can I use? The two methods above replace the text
> with NaNs. How can I make matlab read/import the text also? Thanks

I would use [num,str]=xlsread('filename.xls'); and then combine the two
into a cell array (only a cell array can hold both numbers and strings).
Or, change your workflow after obtaining the data to process the strings
and numbers separately.

Subject: read text and number Excel file

From: A Ram

Date: 1 Oct, 2009 12:55:18

Message: 6 of 17

"Ashish Uthama" <first.last@mathworks.com> wrote in message <op.u04gejfaa5ziv5@uthamaa.dhcp.mathworks.com>...
> On Thu, 01 Oct 2009 08:37:02 -0400, A Ram <shal.hat@gmail.com> wrote:
>
> > dpb <none@non.net> wrote in message
> > <ha0ce7$fmb$1@news.eternal-september.org>...
> >> A Ram wrote:
> >> > Hi,
> >> >
> >> > Am trying to read in an Excel file that contains both text and
> >> numbers without
> >> > getting the text replaced by NaN.
> >> >
> >> ...
> >>
> >> doc xlsread
> >> >> ...
> >> > Empty cells or cells with text create NaNs in the numeric result.
> >> >
> >> > Leading rows and columns of text do not create NaNs in the numeric
> >> > result.
> >> >> ...
> >>
> >>
> >> You'll either have to replace the NaNs after importing or use another
> >> technique afaik.
> >>
> >> --
> >
> >
> >
> > What other technique can I use? The two methods above replace the text
> > with NaNs. How can I make matlab read/import the text also? Thanks
>
> I would use [num,str]=xlsread('filename.xls'); and then combine the two
> into a cell array (only a cell array can hold both numbers and strings).
> Or, change your workflow after obtaining the data to process the strings
> and numbers separately.

Thanks Ashish !
Would you please elaborate on the cell array a bit by code for this case.

Thanks again !

Subject: read text and number Excel file

From: A Ram

Date: 1 Oct, 2009 17:28:19

Message: 7 of 17

"A Ram" <shal.hat@gmail.com> wrote in message <ha28rm$k7r$1@fred.mathworks.com>...
> "Ashish Uthama" <first.last@mathworks.com> wrote in message <op.u04gejfaa5ziv5@uthamaa.dhcp.mathworks.com>...
> > On Thu, 01 Oct 2009 08:37:02 -0400, A Ram <shal.hat@gmail.com> wrote:
> >
> > > dpb <none@non.net> wrote in message
> > > <ha0ce7$fmb$1@news.eternal-september.org>...
> > >> A Ram wrote:
> > >> > Hi,
> > >> >
> > >> > Am trying to read in an Excel file that contains both text and
> > >> numbers without
> > >> > getting the text replaced by NaN.
> > >> >
> > >> ...
> > >>
> > >> doc xlsread
> > >> >> ...
> > >> > Empty cells or cells with text create NaNs in the numeric result.
> > >> >
> > >> > Leading rows and columns of text do not create NaNs in the numeric
> > >> > result.
> > >> >> ...
> > >>
> > >>
> > >> You'll either have to replace the NaNs after importing or use another
> > >> technique afaik.
> > >>
> > >> --
> > >
> > >
> > >
> > > What other technique can I use? The two methods above replace the text
> > > with NaNs. How can I make matlab read/import the text also? Thanks
> >
> > I would use [num,str]=xlsread('filename.xls'); and then combine the two
> > into a cell array (only a cell array can hold both numbers and strings).
> > Or, change your workflow after obtaining the data to process the strings
> > and numbers separately.
>
> Thanks Ashish !
> Would you please elaborate on the cell array a bit by code for this case.
>
> Thanks again !

[num,str]=xlsread('filename.xls');
Does not record all words/str in an array..

I was wondering if there is a better way to read an excel file with words in them
without matlab replacing all words with NaN

Subject: read text and number Excel file

From: dpb

Date: 1 Oct, 2009 17:31:18

Message: 8 of 17

A Ram wrote:
...

> [num,str]=xlsread('filename.xls');
> Does not record all words/str in an array..
>
> I was wondering if there is a better way to read an excel file with words in them
> without matlab replacing all words with NaN

Undoubtedly not the answer you want, but saving the spreadsheet as csv
file and importing that would probably be easier.

I don't use Excel in conjunction w/ ML nor have latest release enough to
know whether one could manage to do direct communication to/from Excel
w/o a lot of grief, but it doesn't appear there is a direct import tool
to import a generic spreadsheet without some limitations on the data
contained therein.

--

Subject: read text and number Excel file

From: A Ram

Date: 1 Oct, 2009 17:54:02

Message: 9 of 17

dpb <none@non.net> wrote in message <ha2p9t$jsl$1@news.eternal-september.org>...
> A Ram wrote:
> ...
>
> > [num,str]=xlsread('filename.xls');
> > Does not record all words/str in an array..
> >
> > I was wondering if there is a better way to read an excel file with words in them
> > without matlab replacing all words with NaN
>
> Undoubtedly not the answer you want, but saving the spreadsheet as csv
> file and importing that would probably be easier.
>
> I don't use Excel in conjunction w/ ML nor have latest release enough to
> know whether one could manage to do direct communication to/from Excel
> w/o a lot of grief, but it doesn't appear there is a direct import tool
> to import a generic spreadsheet without some limitations on the data
> contained therein.
>
> --

Thanks dpq

I tried saving the Excel file both as MS-Dos csv and Windows csv and used csvread, but couldn't load the file

Subject: read text and number Excel file

From: Ashish Uthama

Date: 1 Oct, 2009 18:06:53

Message: 10 of 17

On Thu, 01 Oct 2009 13:28:19 -0400, A Ram <shal.hat@gmail.com> wrote:

> "A Ram" <shal.hat@gmail.com> wrote in message
> <ha28rm$k7r$1@fred.mathworks.com>...
>> "Ashish Uthama" <first.last@mathworks.com> wrote in message
>> <op.u04gejfaa5ziv5@uthamaa.dhcp.mathworks.com>...
>> > On Thu, 01 Oct 2009 08:37:02 -0400, A Ram <shal.hat@gmail.com> wrote:
>> >
>> > > dpb <none@non.net> wrote in message
>> > > <ha0ce7$fmb$1@news.eternal-september.org>...
>> > >> A Ram wrote:
>> > >> > Hi,
>> > >> >
>> > >> > Am trying to read in an Excel file that contains both text and
>> > >> numbers without
>> > >> > getting the text replaced by NaN.
>> > >> >
>> > >> ...
>> > >>
>> > >> doc xlsread
>> > >> >> ...
>> > >> > Empty cells or cells with text create NaNs in the numeric
>> result.
>> > >> >
>> > >> > Leading rows and columns of text do not create NaNs in the
>> numeric
>> > >> > result.
>> > >> >> ...
>> > >>
>> > >>
>> > >> You'll either have to replace the NaNs after importing or use
>> another
>> > >> technique afaik.
>> > >>
>> > >> --
>> > >
>> > >
>> > >
>> > > What other technique can I use? The two methods above replace the
>> text
>> > > with NaNs. How can I make matlab read/import the text also? Thanks
>> >
>> > I would use [num,str]=xlsread('filename.xls'); and then combine the
>> two
>> > into a cell array (only a cell array can hold both numbers and
>> strings).
>> > Or, change your workflow after obtaining the data to process the
>> strings
>> > and numbers separately.
>>
>> Thanks Ashish !
>> Would you please elaborate on the cell array a bit by code for this
>> case.
>>
>> Thanks again !
>
> [num,str]=xlsread('filename.xls');
> Does not record all words/str in an array..

Please elaborate. What data is missed?
A non empty excel cell will either come up as a number in 'num' (a matrix)
or as a string in 'str' (a cell array).

Did you inspect both num and str? If you didnt want 'NaN' in 'num', what
did you want? Note: you would not be able to combine both numbers and
strings meaningfully in a matrix, which is why you have two output
arguments.

I assume you are aware of what a matrix and a cell is in MATLAB. All
explanations would be pointless if not.

If you could show us how the data looks (part of it) and what you want to
do with it after you read it into MATLAB, someone here might be able to
provide easier alternatives in processing the data as XLSREAD returns it.
I would recommend going down this path rather than trying to combine them.

Subject: read text and number Excel file

From: A Ram

Date: 1 Oct, 2009 18:33:02

Message: 11 of 17

"Ashish Uthama" <first.last@mathworks.com> wrote in message <op.u04u9rzta5ziv5@uthamaa.dhcp.mathworks.com>...
> On Thu, 01 Oct 2009 13:28:19 -0400, A Ram <shal.hat@gmail.com> wrote:
>
> > "A Ram" <shal.hat@gmail.com> wrote in message
> > <ha28rm$k7r$1@fred.mathworks.com>...
> >> "Ashish Uthama" <first.last@mathworks.com> wrote in message
> >> <op.u04gejfaa5ziv5@uthamaa.dhcp.mathworks.com>...
> >> > On Thu, 01 Oct 2009 08:37:02 -0400, A Ram <shal.hat@gmail.com> wrote:
> >> >
> >> > > dpb <none@non.net> wrote in message
> >> > > <ha0ce7$fmb$1@news.eternal-september.org>...
> >> > >> A Ram wrote:
> >> > >> > Hi,
> >> > >> >
> >> > >> > Am trying to read in an Excel file that contains both text and
> >> > >> numbers without
> >> > >> > getting the text replaced by NaN.
> >> > >> >
> >> > >> ...
> >> > >>
> >> > >> doc xlsread
> >> > >> >> ...
> >> > >> > Empty cells or cells with text create NaNs in the numeric
> >> result.
> >> > >> >
> >> > >> > Leading rows and columns of text do not create NaNs in the
> >> numeric
> >> > >> > result.
> >> > >> >> ...
> >> > >>
> >> > >>
> >> > >> You'll either have to replace the NaNs after importing or use
> >> another
> >> > >> technique afaik.
> >> > >>
> >> > >> --
> >> > >
> >> > >
> >> > >
> >> > > What other technique can I use? The two methods above replace the
> >> text
> >> > > with NaNs. How can I make matlab read/import the text also? Thanks
> >> >
> >> > I would use [num,str]=xlsread('filename.xls'); and then combine the
> >> two
> >> > into a cell array (only a cell array can hold both numbers and
> >> strings).
> >> > Or, change your workflow after obtaining the data to process the
> >> strings
> >> > and numbers separately.
> >>
> >> Thanks Ashish !
> >> Would you please elaborate on the cell array a bit by code for this
> >> case.
> >>
> >> Thanks again !
> >
> > [num,str]=xlsread('filename.xls');
> > Does not record all words/str in an array..
>
> Please elaborate. What data is missed?
> A non empty excel cell will either come up as a number in 'num' (a matrix)
> or as a string in 'str' (a cell array).
>
> Did you inspect both num and str? If you didnt want 'NaN' in 'num', what
> did you want? Note: you would not be able to combine both numbers and
> strings meaningfully in a matrix, which is why you have two output
> arguments.
>
> I assume you are aware of what a matrix and a cell is in MATLAB. All
> explanations would be pointless if not.
>
> If you could show us how the data looks (part of it) and what you want to
> do with it after you read it into MATLAB, someone here might be able to
> provide easier alternatives in processing the data as XLSREAD returns it.
> I would recommend going down this path rather than trying to combine them.

Thanks Ashish,

I have an Excel file with cells that contain words and other cells that contain numbers. I want to be able to read the file in matlab without loosing the words and numbers. Here is an example to illustrate what I would like to do. Assume the following 2 columns are from Excel

GO_UP_1 3
GO_UP_2 4
GO_UP_3 10
GO_D_1 5
GO_D_2 7
GO_D_3 9

After reading these in matlab, I want to develop a loop that takes the numbers that correspond to GO_UP and place them in a seperate matrix, and take the numbers that correspond to GO_D and place them in a separate matrix. For example the number that corresponds to GO_UP_1 is 3 according to the above two columns.

Thanks !!!

Subject: read text and number Excel file

From: Ashish Uthama

Date: 1 Oct, 2009 19:10:16

Message: 12 of 17

On Thu, 01 Oct 2009 14:33:02 -0400, A Ram <shal.hat@gmail.com> wrote:

> "Ashish Uthama" <first.last@mathworks.com> wrote in message
> <op.u04u9rzta5ziv5@uthamaa.dhcp.mathworks.com>...
>> On Thu, 01 Oct 2009 13:28:19 -0400, A Ram <shal.hat@gmail.com> wrote:
>>
>> > "A Ram" <shal.hat@gmail.com> wrote in message
>> > <ha28rm$k7r$1@fred.mathworks.com>...
>> >> "Ashish Uthama" <first.last@mathworks.com> wrote in message
>> >> <op.u04gejfaa5ziv5@uthamaa.dhcp.mathworks.com>...
>> >> > On Thu, 01 Oct 2009 08:37:02 -0400, A Ram <shal.hat@gmail.com>
>> wrote:
>> >> >
>> >> > > dpb <none@non.net> wrote in message
>> >> > > <ha0ce7$fmb$1@news.eternal-september.org>...
>> >> > >> A Ram wrote:
>> >> > >> > Hi,
>> >> > >> >
>> >> > >> > Am trying to read in an Excel file that contains both text and
>> >> > >> numbers without
>> >> > >> > getting the text replaced by NaN.
>> >> > >> >
>> >> > >> ...
>> >> > >>
>> >> > >> doc xlsread
>> >> > >> >> ...
>> >> > >> > Empty cells or cells with text create NaNs in the numeric
>> >> result.
>> >> > >> >
>> >> > >> > Leading rows and columns of text do not create NaNs in the
>> >> numeric
>> >> > >> > result.
>> >> > >> >> ...
>> >> > >>
>> >> > >>
>> >> > >> You'll either have to replace the NaNs after importing or use
>> >> another
>> >> > >> technique afaik.
>> >> > >>
>> >> > >> --
>> >> > >
>> >> > >
>> >> > >
>> >> > > What other technique can I use? The two methods above replace the
>> >> text
>> >> > > with NaNs. How can I make matlab read/import the text also?
>> Thanks
>> >> >
>> >> > I would use [num,str]=xlsread('filename.xls'); and then combine
>> the
>> >> two
>> >> > into a cell array (only a cell array can hold both numbers and
>> >> strings).
>> >> > Or, change your workflow after obtaining the data to process the
>> >> strings
>> >> > and numbers separately.
>> >>
>> >> Thanks Ashish !
>> >> Would you please elaborate on the cell array a bit by code for this
>> >> case.
>> >>
>> >> Thanks again !
>> >
>> > [num,str]=xlsread('filename.xls');
>> > Does not record all words/str in an array..
>>
>> Please elaborate. What data is missed?
>> A non empty excel cell will either come up as a number in 'num' (a
>> matrix)
>> or as a string in 'str' (a cell array).
>>
>> Did you inspect both num and str? If you didnt want 'NaN' in 'num', what
>> did you want? Note: you would not be able to combine both numbers and
>> strings meaningfully in a matrix, which is why you have two output
>> arguments.
>>
>> I assume you are aware of what a matrix and a cell is in MATLAB. All
>> explanations would be pointless if not.
>>
>> If you could show us how the data looks (part of it) and what you want
>> to
>> do with it after you read it into MATLAB, someone here might be able to
>> provide easier alternatives in processing the data as XLSREAD returns
>> it.
>> I would recommend going down this path rather than trying to combine
>> them.
>
> Thanks Ashish,
>
> I have an Excel file with cells that contain words and other cells that
> contain numbers. I want to be able to read the file in matlab without
> loosing the words and numbers. Here is an example to illustrate what I
> would like to do. Assume the following 2 columns are from Excel
>
> GO_UP_1 3
> GO_UP_2 4
> GO_UP_3 10
> GO_D_1 5
> GO_D_2 7
> GO_D_3 9
>
> After reading these in matlab, I want to develop a loop that takes the
> numbers that correspond to GO_UP and place them in a seperate matrix,
> and take the numbers that correspond to GO_D and place them in a
> separate matrix. For example the number that corresponds to GO_UP_1 is 3
> according to the above two columns.
>
> Thanks !!!

Thats better :)

Read the above using XLSREAD
Inspect 'num' and 'str'
Use STRMATCH on 'str' to obtain the row index of GO_UP/GO_DOWN
Since the row number is the same for num/str. Use the indices obtained
 from the previous step to extract the required numbers from 'num'

Or in short:

[n s]=xlsread('somefile.xlsx')
matchingInds=strmatch('GO_UP',s)
n(matchingInds)

Subject: read text and number Excel file

From: A Ram

Date: 1 Oct, 2009 19:24:03

Message: 13 of 17

"Ashish Uthama" <first.last@mathworks.com> wrote in message <op.u04x7etda5ziv5@uthamaa.dhcp.mathworks.com>...
> On Thu, 01 Oct 2009 14:33:02 -0400, A Ram <shal.hat@gmail.com> wrote:
>
> > "Ashish Uthama" <first.last@mathworks.com> wrote in message
> > <op.u04u9rzta5ziv5@uthamaa.dhcp.mathworks.com>...
> >> On Thu, 01 Oct 2009 13:28:19 -0400, A Ram <shal.hat@gmail.com> wrote:
> >>
> >> > "A Ram" <shal.hat@gmail.com> wrote in message
> >> > <ha28rm$k7r$1@fred.mathworks.com>...
> >> >> "Ashish Uthama" <first.last@mathworks.com> wrote in message
> >> >> <op.u04gejfaa5ziv5@uthamaa.dhcp.mathworks.com>...
> >> >> > On Thu, 01 Oct 2009 08:37:02 -0400, A Ram <shal.hat@gmail.com>
> >> wrote:
> >> >> >
> >> >> > > dpb <none@non.net> wrote in message
> >> >> > > <ha0ce7$fmb$1@news.eternal-september.org>...
> >> >> > >> A Ram wrote:
> >> >> > >> > Hi,
> >> >> > >> >
> >> >> > >> > Am trying to read in an Excel file that contains both text and
> >> >> > >> numbers without
> >> >> > >> > getting the text replaced by NaN.
> >> >> > >> >
> >> >> > >> ...
> >> >> > >>
> >> >> > >> doc xlsread
> >> >> > >> >> ...
> >> >> > >> > Empty cells or cells with text create NaNs in the numeric
> >> >> result.
> >> >> > >> >
> >> >> > >> > Leading rows and columns of text do not create NaNs in the
> >> >> numeric
> >> >> > >> > result.
> >> >> > >> >> ...
> >> >> > >>
> >> >> > >>
> >> >> > >> You'll either have to replace the NaNs after importing or use
> >> >> another
> >> >> > >> technique afaik.
> >> >> > >>
> >> >> > >> --
> >> >> > >
> >> >> > >
> >> >> > >
> >> >> > > What other technique can I use? The two methods above replace the
> >> >> text
> >> >> > > with NaNs. How can I make matlab read/import the text also?
> >> Thanks
> >> >> >
> >> >> > I would use [num,str]=xlsread('filename.xls'); and then combine
> >> the
> >> >> two
> >> >> > into a cell array (only a cell array can hold both numbers and
> >> >> strings).
> >> >> > Or, change your workflow after obtaining the data to process the
> >> >> strings
> >> >> > and numbers separately.
> >> >>
> >> >> Thanks Ashish !
> >> >> Would you please elaborate on the cell array a bit by code for this
> >> >> case.
> >> >>
> >> >> Thanks again !
> >> >
> >> > [num,str]=xlsread('filename.xls');
> >> > Does not record all words/str in an array..
> >>
> >> Please elaborate. What data is missed?
> >> A non empty excel cell will either come up as a number in 'num' (a
> >> matrix)
> >> or as a string in 'str' (a cell array).
> >>
> >> Did you inspect both num and str? If you didnt want 'NaN' in 'num', what
> >> did you want? Note: you would not be able to combine both numbers and
> >> strings meaningfully in a matrix, which is why you have two output
> >> arguments.
> >>
> >> I assume you are aware of what a matrix and a cell is in MATLAB. All
> >> explanations would be pointless if not.
> >>
> >> If you could show us how the data looks (part of it) and what you want
> >> to
> >> do with it after you read it into MATLAB, someone here might be able to
> >> provide easier alternatives in processing the data as XLSREAD returns
> >> it.
> >> I would recommend going down this path rather than trying to combine
> >> them.
> >
> > Thanks Ashish,
> >
> > I have an Excel file with cells that contain words and other cells that
> > contain numbers. I want to be able to read the file in matlab without
> > loosing the words and numbers. Here is an example to illustrate what I
> > would like to do. Assume the following 2 columns are from Excel
> >
> > GO_UP_1 3
> > GO_UP_2 4
> > GO_UP_3 10
> > GO_D_1 5
> > GO_D_2 7
> > GO_D_3 9
> >
> > After reading these in matlab, I want to develop a loop that takes the
> > numbers that correspond to GO_UP and place them in a seperate matrix,
> > and take the numbers that correspond to GO_D and place them in a
> > separate matrix. For example the number that corresponds to GO_UP_1 is 3
> > according to the above two columns.
> >
> > Thanks !!!
>
> Thats better :)
>
> Read the above using XLSREAD
> Inspect 'num' and 'str'
> Use STRMATCH on 'str' to obtain the row index of GO_UP/GO_DOWN
> Since the row number is the same for num/str. Use the indices obtained
> from the previous step to extract the required numbers from 'num'
>
> Or in short:
>
> [n s]=xlsread('somefile.xlsx')
> matchingInds=strmatch('GO_UP',s)
> n(matchingInds)

Thanks !!

However I keep getting this error:

??? Error using ==> xlsread at 234
File contains unexpected record length. Try saving as Excel 98.

Subject: read text and number Excel file

From: dpb

Date: 1 Oct, 2009 19:42:27

Message: 14 of 17

A Ram wrote:
...
> However I keep getting this error:
>
> ??? Error using ==> xlsread at 234
> File contains unexpected record length. Try saving as Excel 98.

So, did you try after resaving the xls file in the V98 format?

Apparently the version of ML you're using didn't recognize (a hopefully
later) Excel-specific form. You'll have to do a "Save As" and then
select that (or presumably an earlier) version.

--

Subject: read text and number Excel file

From: dpb

Date: 1 Oct, 2009 19:43:27

Message: 15 of 17

A Ram wrote:
...

> I tried saving the Excel file both as MS-Dos csv and Windows csv and
> used csvread, but couldn't load the file

So, why not and what did the csv file look like? My crystal ball is in
the shop, sorry.

--

Subject: read text and number Excel file

From: Steven Lord

Date: 1 Oct, 2009 19:54:00

Message: 16 of 17


"A Ram" <shal.hat@gmail.com> wrote in message
news:ha2orj$cg0$1@fred.mathworks.com...

*snip*

> [num,str]=xlsread('filename.xls');
> Does not record all words/str in an array..
>
> I was wondering if there is a better way to read an excel file with words
> in them
> without matlab replacing all words with NaN

Use the three-output form of XLSREAD and extract the appropriate pieces of
data in which you're interested from the third output? See HELP XLSREAD.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Subject: read text and number Excel file

From: Kaylee

Date: 20 Nov, 2013 21:36:06

Message: 17 of 17

"A Ram" wrote in message <ha0b5a$3cu$1@fred.mathworks.com>...
> Hi,
>
> Am trying to read in an Excel file that contains both text and numbers without
> getting the text replaced by NaN.
>
> I tried the following, but NON worked:
>
> [num,str]=xlsread('filename.xls');
>
> and
>
> Name = xlsread('filename.xls');
>
> Thanks !

Use something like [num, txt, all] = xlsread(__).
num -- are the numbers only
txt -- is the text only
all -- is both numbers and the text

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