Importing specific cell from excel file using variables.

I haven't been able to get around this problem, don't know if it is doable at all. I would appreciate some help
I have a simple problem, at least that's what I think, the code is
A= xlsread('Per.xls', sheet1, 'G2:G2')
Is there a way of retrieving the data by having that "2" in the cell range part be a variable? In other words I want to retrieve a specific cell using input giving by the user, which he/she should be able to change.
Any ideas??

 采纳的回答

Alejandro - if you have a variable that indicates which cell range you wish to extract data from, then you can easily use this as an input to xlsread. For example,
myRange = 2;
myCells = sprintf('G1:G%d',myRange);
A = xlsread('Per.xls', sheet1, myCells);
Note how we use sprintf to build a string that we can pass to xlsread.

更多回答(0 个)

类别

帮助中心File 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