Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to Select Entire Row From Excel File Uisng Prompt?
Date: Tue, 20 Nov 2012 03:11:09 +0000 (UTC)
Organization: HSBC
Lines: 36
Message-ID: <k8escd$5mq$1@newscl01ah.mathworks.com>
References: <k899g1$cb2$1@newscl01ah.mathworks.com> <k8b90m$4g8$1@newscl01ah.mathworks.com> <k8bt7h$8r3$1@newscl01ah.mathworks.com> <k8c9se$iqk$1@newscl01ah.mathworks.com> <k8dbrr$7d3$1@newscl01ah.mathworks.com> <k8ecid$eop$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-03-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1353381069 5850 172.30.248.48 (20 Nov 2012 03:11:09 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 20 Nov 2012 03:11:09 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2921053
Xref: news.mathworks.com comp.soft-sys.matlab:783116

Sorry to bother you, but I think there is something wrong with your function.  At first I thought it may have something to do with the dates.  I tried integers and text; nothing worked.

requireDateNumber = 'C';

data = xlsread('C:\Program Files\MATLAB\R2012a\StockSymbols.xls');
rowIndex = (data(:,1) == requiredDateNumber);

if any(rowIndex)
  rowData = data(rowIndex,2:end);
else
  error('There is no corresponding row.');
end

Here is the error:
Error in Read_Specific_Row (line 34)
rowIndex = (data(:,1) == requiredDateNumber);


'requireDateNumber' must be just a variable.  It doesn't have to be a date, or numeric, or anything specific, right.


"Phil Goddard" <phil@goddardconsulting.ca> wrote in message <k8ecid$eop$1@newscl01ah.mathworks.com>...
> You need to do error checking, and I am assuming your file is as per one of your previous posts whether the first column is read in as integer numbers (which can be interpreted as dates):
> 
> requireDateNumber = %whatever your user enters
> 
> data = xlsread('myfile.xls');
> rowIndex = (data(:,1) == requiredDateNumber);
> 
> if any(rowIndex)
>   rowData = data(rowIndex,2:end);
> else
>   error('There is no corresponding row.');
> end
> 
> Phil.