Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Import Data from excel sheet

Status
Not open for further replies.

ysg519

Mechanical
Sep 1, 2007
17
I have a .xls sheet which consists of strings and numerics. I want to load it into a matrix in order to do further calculations etc. The xlsread function in matlab works only if the strings are placed in the header. In my case however it does not work since the strings are placed in several columns. Please help.

Thanks

 
Replies continue below

Recommended for you

clear as mud. show example/demo of your sheet or better description of what is in the numeric and text arrays from xlsread. Sometimes you can format an extra sheet in the workbook which is actually characters (text) but looks like numbers. Then all characters will be in one text array. Just convert to nums.
 
cibachrome,
I have attached a sample file to show the kind of data I have in it. I want to import this data into a matrix in matlab. Once imported into a matrix say A, I would like to access the elements of this matrix irrespective of it being a number or a string. I hope that is clearer now. Thanks
 
 http://files.engineering.com/getfile.aspx?folder=b2671047-bfd6-4062-8a98-9fbd4bb9d4e5&file=Book1.xls
[num,txt,A]=xlsread('c:\temp\book1.xls');
A:),size(num,2)+1:end)=[]; % You have some extra crap in there. Delete it.

A{2,2} % Use curly braces for addressing cell contents
A{end,end} % make sure we got it.

isnumeric(A{1,1}) % checks before dealing with contents
ischar(A{4,2})
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor