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??

 採用された回答

Geoff Hayes
Geoff Hayes 2015 年 2 月 16 日

0 投票

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.

1 件のコメント

Alejandro
Alejandro 2015 年 2 月 16 日
Appreciate the help!! Thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Import from MATLAB についてさらに検索

タグ

質問済み:

2015 年 2 月 15 日

コメント済み:

2015 年 2 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by