From: Eric Durant Subject: Re: Help Excel to Matlab, strings and numeric values Date: 14 Jul 2000 00:00:00 GMT Message-ID: <396F546E.6CC820D@umich.edu> Content-Transfer-Encoding: 7bit References: <8F6EAF82davidn3webnet@205.233.108.180> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@eecs.umich.edu X-Trace: news.eecs.umich.edu 963597253 43449 141.213.12.216 (14 Jul 2000 17:54:13 GMT) Organization: EECS Dept. Univ. of Michigan Mime-Version: 1.0 Newsgroups: comp.soft-sys.matlab Matlab 5.3.1 has a similar problem when fetching data from Access 2000. Using the numeric mode option of DDEREQ ([1 0]), the last tuple is always dropped. When fetching in numeric mode, strings are converted to the number 0. When talking to Access, the string format data returned is tab-delimited, so you can parse it through DLMREAD to get a numeric matrix. Here's the code I use to parse data from Access. If Excel returns tab-delimited data, this should work if you make the appropriate modifications to the DDEREQ call: =========================== dataString = ddereq(datachannel,'Data',[1 1]); if isempty(dataString) error('Error while in DDEREQ') elseif ~ischar(dataString) % Matlab 5.3.1 on WinNT4 returns the 1x1 double 0 on % large (>~500 kB) result sets error('Undocumented (non-char) return type from DDEREQ') end fn = tempname; fid = fopen(fn, 'w'); if fid==-1 error('Could not open temporary file') end count = fwrite(fid, dataString); st = fclose(fid); matrix = dlmread(fn, '\t'); delete(fn) =========================== -- Eric Durant http://edurant.com/ David Nyarko wrote: >I have data in Excel in which some of the columns are strings >and some numerical values. I want to be able to read selected >rows and columns into a MATLAB matrix and perform >manipulations on the numeric values. My function is shown below >as well as an example call to extract information from >r1c1:r5c4 in the open EXCEL document (welltest1.xls) >The problem I have is that the resulting MATLAB array displays >correctly on the screen as shown, but the 'ischar' function >indicates it is a character array, thus making it difficult to >extract the numeric values in the actual EXCEL cells. [...]