From: Brandon Cochenour on 20 May 2010 13:20 Perhaps not "new"...but one that maybe isn't talked about as much. In other words, yes, I know there is some limited functionality with the Excel functions on Mac/Unix machines. However, I've run into a curious thing though for all you Mac users... I loaded an Excel file that contained both text and numbers. Because of the limited functionality, you have no choice but to load in the whole file. My file looks like this... Apples Oranges Grapes 0.1 0.2 0.3 0.4 0.5 Using the data=xlsread(filename) command returns the following data= NaN NaN NaN 0.1 0.2 0.3 0.4 0.5 As mentioned, this is to be expected given the limited functionality. If you do length(data), you get the error message, "Subscript indicies must either be real positive integers or logicals". Presumably because of those NaN's which are a fact of life because you can't specify a range in the 'basic' mode. (And by presumably, I really mean, I don't know why.) (Also...you can get the text portion by calling [data text]=xlsread(filename). Your 'text' variable would contain only the text...while the 'data' variable would contain the same as seen above.) So...I tried to index 'data' so that it was just an array of numbers. i.e. - numbers=data(4:8) Performing the same length command... lenght(numbers)...you still get the same error message. It's like whatever is screwing up you ability to index when you import text AND numbers from Excel initially, stays around, even if you try to cut out the text portion of the sheet. As a test...I created a new dummy Excel file that only had numbers (no text). Importing that dummy file into Matlab using the xlsread command...then going through and indexing the data as you wish and calling the "length" command yields no issues. Ok...if your sheet starts with no text, you're fine...but if you have numbers AND text, there seems to be an issue. Question 1: Anyone have any idea why this is? I thought I'd be clever, and save my 'numbers' array into a new spreadsheet using the xlswrite command. Then...load in my clever new spreadsheet, that only consisted of numbers, which I know from the previous test seemed to work ok. Surprisingly, this STILL returned the same error message. It's as is Matlab somehow remembered that the "numbers" array had originally come from an Excel sheet that originally contained BOTH text and numbers. How can this be?!?! In summary....I'm fine with not being able to define ranges when I initially call xlsread. I just assumed that I'd be able to do it myself once I had the entire sheet in Matlab. However...it seems that Matlab handles sheets with text and numbers differently than it does sheets with just numbers. Any ideas/work arounds here? --- Brandon
From: Doug Schwarz on 20 May 2010 13:38 Brandon Cochenour wrote: [snip] > If you do length(data), you get the error message, "Subscript indicies > must either be real positive integers or logicals". You get this error message because you have defined a variable called "length" in your workspace and MATLAB is attempting to index into it with the variable "data". It is not trying to run the length function. You need to remove this variable. You also might find the *third* output variable from xlsread to be useful. Read the help info. -- Doug Schwarz dmschwarz&ieee,org Make obvious changes to get real email address.
From: Brandon Cochenour on 20 May 2010 13:48 What a bonehead mistake. Indeed...I did let myself define a variable "length". I know better! Boy...I wrote an epic post for all of that.... Regarding your second item...according to the Help...the "raw" output variable is not available on Mac (see COM Server Requirements). Doug Schwarz <see(a)sig.for.address.edu> wrote in message <bseJn.13596$h57.11781(a)newsfe22.iad>... > Brandon Cochenour wrote: > [snip] > > > If you do length(data), you get the error message, "Subscript indicies > > must either be real positive integers or logicals". > > You get this error message because you have defined a variable called > "length" in your workspace and MATLAB is attempting to index into it > with the variable "data". It is not trying to run the length function. > You need to remove this variable. > > You also might find the *third* output variable from xlsread to be > useful. Read the help info. > > -- > Doug Schwarz > dmschwarz&ieee,org > Make obvious changes to get real email address.
From: Brandon Cochenour on 20 May 2010 13:50 What a bonehead mistake. Indeed...I did let myself define a variable "length". I know better! Boy...I wrote an epic post for all of that.... Regarding your second item...according to the Help...the "raw" output variable is not available on Mac (see COM Server Requirements). Doug Schwarz <see(a)sig.for.address.edu> wrote in message <bseJn.13596$h57.11781(a)newsfe22.iad>... > Brandon Cochenour wrote: > [snip] > > > If you do length(data), you get the error message, "Subscript indicies > > must either be real positive integers or logicals". > > You get this error message because you have defined a variable called > "length" in your workspace and MATLAB is attempting to index into it > with the variable "data". It is not trying to run the length function. > You need to remove this variable. > > You also might find the *third* output variable from xlsread to be > useful. Read the help info. > > -- > Doug Schwarz > dmschwarz&ieee,org > Make obvious changes to get real email address.
From: Walter Roberson on 20 May 2010 14:18 "Brandon Cochenour" <bcochen.removethis(a)nscu.edu> wrote in message <ht3r0m$rrp$1(a)fred.mathworks.com>... > I loaded an Excel file that contained both text and numbers. Because of the limited functionality, you have no choice but to load in the whole file. My file looks like this... > Using the data=xlsread(filename) command returns the following > > data= > NaN > NaN > NaN > 0.1 > 0.2 > 0.3 > 0.4 > 0.5 > > As mentioned, this is to be expected given the limited functionality. If you do length(data), you get the error message, "Subscript indicies must either be real positive integers or logicals". It is quite likely that you have defined an array named "length".
|
Next
|
Last
Pages: 1 2 Prev: Poisson (Distribution) Parameter Next: Dotted line between points while using ginput? |