Prev: Problems using Real-Time Workshop and Wave Device
Next: calllib function problem: Index exceeds matrix dimensions
From: Senthan Mathavan on 16 Jul 2010 06:16 Could anyone help me with the following: I need to read a single column of 900 elements from an excel file. The nemubers that I'm intereted in are in Sheet 1. The following code works fine A = xlsread('mathu.xls', 1, 'A3:A902'); However when I tried automate the process to read off several successive columns, as given below, it doesn't work! For example, j=3; P=sprintf('A%d', j); % returns P=A3 Q=sprintf('A%d', j+899); % returns Q=A902 A = xlsread('mathu.xls', 1, 'P:Q'); A null array is returned for array A! Any suggestions? Thanks Mathavan
From: Steven Lord on 16 Jul 2010 09:50 "Senthan Mathavan" <s.mathavan(a)lboro.ac.uk> wrote in message news:i1pbh6$4on$1(a)fred.mathworks.com... > Could anyone help me with the following: > > I need to read a single column of 900 elements from an excel file. The > nemubers that I'm intereted in are in Sheet 1. > > The following code works fine > A = xlsread('mathu.xls', 1, 'A3:A902'); > > However when I tried automate the process to read off several successive > columns, as given below, it doesn't work! > > For example, > > j=3; > P=sprintf('A%d', j); % returns P=A3 > Q=sprintf('A%d', j+899); % returns Q=A902 > A = xlsread('mathu.xls', 1, 'P:Q'); > > A null array is returned for array A! You don't have anything in columns P or Q of your sheet, do you? Try this instead: A = xlsread('mathu.xls', [P ':' Q]); -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
From: Senthan Mathavan on 16 Jul 2010 10:12
Awesome! Your command works fine! Yes, I didn't have anything in either P or Q... Many thanks Steve!!! Cheers Mathavan |