Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: xlsread modification

Subject: xlsread modification

From: chaos

Date: 19 Jun, 2008 20:24:02

Message: 1 of 5

If excel file, say temp.xls, has data like this,

'A' 10
'B' 20

and if I use

[dNum, dTxt] = xlsread('temp.xls');

It gives me dNum = [10;20]

I want MATLAB to give me [nan 10; nan 20]. I tried to use a
function which overwrites MATLAB but it gets complicated.

Anybody knows easier way to solve this problem.

I checked xlsread function apparently it has data in the
format that I need but it later chops NaNs from the first
columns. I don't want to changed default xlsread.

Any solutions will be appreciated.

Chaos

Subject: xlsread modification

From: tristram.scott@ntlworld.com (Tristram Scott)

Date: 20 Jun, 2008 10:04:01

Message: 2 of 5

Chaos <achordedrose@gmail.com> wrote:
> If excel file, say temp.xls, has data like this,
>
> 'A' 10
> 'B' 20
>
> and if I use
>
> [dNum, dTxt] = xlsread('temp.xls');
>
> It gives me dNum = [10;20]
>
> I want MATLAB to give me [nan 10; nan 20]. I tried to use a
> function which overwrites MATLAB but it gets complicated.
>
> Anybody knows easier way to solve this problem.
>
> I checked xlsread function apparently it has data in the
> format that I need but it later chops NaNs from the first
> columns. I don't want to changed default xlsread.
>

Later versions of xlsread (MATLAB 7 onwards (yuck)) running under Windows
(yuck) where a copy of Excel (yuck) is installed have three return
arguments available. The first two are as you used them, the third is a
cell array of all the data, both numeric and text. You can use this third
return argument as the basis of your own code. I do something a bit like
this:

[data,s1,cc] = xlsread(ffn,sn);
[cm,cn] = size(cc); % Size of cell array of all data
ncc = cellfun(@isnumeric,cc); % Find the numeric data in cc
nonnancc = ncc; % Numeric and not nan
nonnancc(ncc) = ~cellfun(@isnan,cc(ncc)); % Fill it in



--
Dr Tristram J. Scott
Energy Consultant

Subject: xlsread modification

From: Loren Shure

Date: 20 Jun, 2008 12:26:46

Message: 3 of 5

In article <lgL6k.5591$Nn.1451@newsfe09.ams2>,
tristram.scott@ntlworld.com says...
> Chaos <achordedrose@gmail.com> wrote:
> > If excel file, say temp.xls, has data like this,
> >
> > 'A' 10
> > 'B' 20
> >
> > and if I use
> >
> > [dNum, dTxt] = xlsread('temp.xls');
> >
> > It gives me dNum = [10;20]
> >
> > I want MATLAB to give me [nan 10; nan 20]. I tried to use a
> > function which overwrites MATLAB but it gets complicated.
> >
> > Anybody knows easier way to solve this problem.
> >
> > I checked xlsread function apparently it has data in the
> > format that I need but it later chops NaNs from the first
> > columns. I don't want to changed default xlsread.
> >
>
> Later versions of xlsread (MATLAB 7 onwards (yuck)) running under Windows
> (yuck) where a copy of Excel (yuck) is installed have three return
> arguments available. The first two are as you used them, the third is a
> cell array of all the data, both numeric and text. You can use this third
> return argument as the basis of your own code. I do something a bit like
> this:
>
> [data,s1,cc] = xlsread(ffn,sn);
> [cm,cn] = size(cc); % Size of cell array of all data
> ncc = cellfun(@isnumeric,cc); % Find the numeric data in cc
> nonnancc = ncc; % Numeric and not nan
> nonnancc(ncc) = ~cellfun(@isnan,cc(ncc)); % Fill it in
>
>
>
>

Without trying to ignite flames, any chance you'd share with us why you
say "... (MATLAB 7 onwards (yuck))..."?

--
Loren
http://blogs.mathworks.com/loren/

Subject: xlsread modification

From: chaos

Date: 20 Jun, 2008 15:03:02

Message: 4 of 5

Loren Shure <loren@mathworks.com> wrote in message
>
> Without trying to ignite flames, any chance you'd share
with us why you
> say "... (MATLAB 7 onwards (yuck))..."?


I guess you don't have issues with Microsoft and Exel yucks.
Those yucks are universal. Although I personally don't have
any issues with Matlab 7 & onwards. I know many people who
don't like some features in new Matlab.

1. It has lot of GUI stuff which slows the computers.
2. It doesn't have webserver.

V

Subject: xlsread modification

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 20 Jun, 2008 17:06:19

Message: 5 of 5

In article <g3ggr6$si9$1@fred.mathworks.com>,
Chaos <achordedrose@gmail.com> wrote:

>I know many people who
>don't like some features in new Matlab.

>1. It has lot of GUI stuff which slows the computers.
>2. It doesn't have webserver.

This samosa I brought for my lunch doesn't have a webserver either,
but I intend to enjoy eating it anyhow.

Perhaps you could expand upon your webserver comment, indicating
more clearly what functionality is missing and why that is a significant
problem?
--
  "Nothing recedes like success." -- Walter Winchell

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
xlsread Chaos 19 Jun, 2008 16:25:13
excel Chaos 19 Jun, 2008 16:25:13
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics