reading from excel by page

3 次查看(过去 30 天)
Kris Lawson
Kris Lawson 2016-3-23
Hello,
I'm looking to read from 1 excel document that consists of 3 pages of information(EMG) each consisting of 19col. 44000rows
I would like to know how to manipulate cells from seperate pages as well as how to cross corolate between pages, if at all possible. (would it be easier from a text file?)
Any help would be greatly appreciated.
1st time Matlab user.
  3 个评论
Kris Lawson
Kris Lawson 2016-3-24
yes the information is 3 sheets for pre, post, and follow up. The data on each sheet has the same number of input fields rows/col.
KSSV
KSSV 2016-3-24
using xlsread you can read the sheet you want.

请先登录,再进行评论。

回答(1 个)

John BG
John BG 2016-3-24
Kris
the page of a Microsoft Excel workbook can be directly addressed in the command xlsread:
filename='wrkbk1.xlsx'
read_sheet = 3
read_range = 'B2:C3'
[num,txt,raw]=xlsread(filename,read_sheet,read_range)
the extracted data is in num. Once whatever data in MATLAB you can process it with any operation you want, and once ready you can store it back in same or another Excel spread sheet with command xlswrite that has format
xlswrite(file,A,write_sheet,write_range)
If you find this answer of any help solving your question, please click on the thumbs-up vote link,
thanks in advance
John
  3 个评论
John BG
John BG 2016-3-26
for instance, there is an excel file called ShipData.xlsx that looks like this:
When reading with
[num,txt,raw]=xlsread('ShipData.xlsx','ShipData','A1:B10')
you get the following
num =
9180401.00
9376036.00
9354868.00
9573000.00
9179397.00
9293545.00
9707792.00
8972194.00
9148142.00
txt =
'Register Number' 'IMO Number'
'12536D' ''
'14968W' ''
'16283B' ''
'15126T' ''
'06466F' ''
'04893V' ''
'22394T' ''
'962G60' ''
'39Y697' ''
raw =
'Register Number' 'IMO Number'
'12536D' [9180401.00]
'14968W' [9376036.00]
'16283B' [9354868.00]
'15126T' [9573000.00]
'06466F' [9179397.00]
'04893V' [9293545.00]
'22394T' [9707792.00]
'962G60' [8972194.00]
'39Y697' [9148142.00]
the file name can be the same or a different file, it's up to you.
Hope it helps.
Regarding your design reasoning, i rather not go through it until you have a script that, working or crashing, is a concise start point for another question or comment.
John
Kris Lawson
Kris Lawson 2016-3-26
Ok. Thank you very much for clearing that up for me.
I will post again when I have some code underway.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Data Import from MATLAB 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by