From: Jeff on 24 May 2010 14:24 I am attempting to import some data from Excel using xlsread. Everything is working fine except in one particular case. Every now and then it'll come across a cell whose value is too long and it will import a NaN. When Excel is opened ###### is displayed. However, when you click on the cell the value is there. Also, if I import using the import feature from the command window it works fine. I need to do this programmatically and therefore would like to continue using xlsread. Any sugestions? Thanks in advance, Jeff
From: Walter Roberson on 24 May 2010 14:55 Jeff wrote: > I am attempting to import some data from Excel using xlsread. Everything > is working fine except in one particular case. Every now and then it'll > come across a cell whose value is too long and it will import a NaN. NaN only applies to floating point fields, so the implication is that the field is numeric. What do you mean by "too long" for a numeric value? Do you mean that the string of digits is more than 308 digits before the decimal point and so the numeric value exceeds 1E308? Perhaps a specific example would help. As you have Excel installed, the implication is that you on either Windows or Mac. If you are using Windows then xlsread would talk via DCOM to Excel and get it to read the data. If all of your data is numeric and you can skip any header lines, then you can use dlmread(). If you need something more complex, then textscan() may be appropriate.
From: tinne123 on 24 May 2010 16:49 Hi, Jeff maybe it's very stupid what I write - as, sorry, I am under a deadline pressure so I won't verify my guess - but just from reading your post, my impression is that some of your values are displayed in Excel as ######## bcs: - the cell format 'd be Format / Cells / Number / Number with a relatively high number of decimal places, and at the same time, - while the corresponding Format / Column / Width is rather narrow. Iif this is what causes your troubles then I fancy the problem is not primarily with your Matlab code. As to overcome the problem, no idea whether it is quicker / easier for you to rewrite your Matlab codes as Walter Robertson suggested to replace xlsread for other commnads - or, to adjust the formats in your Excel files - especially if xlsread is universal wrt numeric and string values? Take this just as a random idea to verify... Good luck!!
From: TideMan on 24 May 2010 17:40 On May 25, 6:24 am, "Jeff " <jag...(a)yahoo.com> wrote: > I am attempting to import some data from Excel using xlsread. Everything is working fine except in one particular case. Every now and then it'll come across a cell whose value is too long and it will import a NaN. When Excel is opened ###### is displayed. However, when you click on the cell the value is there. Also, if I import using the import feature from the command window it works fine. I need to do this programmatically and therefore would like to continue using xlsread. Any sugestions? > > Thanks in advance, > > Jeff There is obviously something fishy about that cell. Have you looked at it in the cell array txt (3rd output argument)? Show us what it looks like by typing: txt{icol,irow} where icol and irow define its position. I suspect that a stray character has slipped in there and it is no longer numeric.
From: ade77 on 24 May 2010 19:56
"Jeff " <jagymg(a)yahoo.com> wrote in message <hteg84$pmf$1(a)fred.mathworks.com>... > I am attempting to import some data from Excel using xlsread. Everything is working fine except in one particular case. Every now and then it'll come across a cell whose value is too long and it will import a NaN. When Excel is opened ###### is displayed. However, when you click on the cell the value is there. Also, if I import using the import feature from the command window it works fine. I need to do this programmatically and therefore would like to continue using xlsread. Any sugestions? > > Thanks in advance, > > Jeff From excel point of view, ##### normarlly occur when you have a date format in a column or cell , and the column width is too small to display it. Now MATLAB will not import the dates alongside the numbers, as a single matrix, that is why it will display it as NaN, becuase a 'date' is not a number. For example if you have : 4 7 3/4/2010 5 8 3/5/2010 when you import, you will get:; 4 7 NaN 5 8 NaN However, if you use the three output of xlsread, you should see your date in a cell as some posters have suggested. Finally, you said sometimes it will work, sometimes it will not work, I assume you are either manually changing the format of the cell to say serial date, or other format, or your excel is screwed. Perhaps, if you can tell us the exact format of the cell in question, it will help. Good luck |