Using a variable range with xlsread??

Hello, I am trying to use xlsread, but I need the range to be variables. for example:
str1 = 'A1'; str2 = 'B5'; Input = xlsread(filename,'str1:str2');
However, this is giving me the following error: "Data range is invalid." Is there a way to do this? Thanks!
-Matt

回答 (1 件)

Jan
Jan 2011 年 6 月 13 日

3 投票

'str1:str2' is the string 'str1:str2' - not surprising. But you want to concatenate two (three!) string variables:
str1 = 'A1';
str2 = 'B5';
Input = xlsread(filename,[str1, ':', str2]);
Such methods are explained in the Getting Started chapters of the documentation.

カテゴリ

ヘルプ センター および File ExchangeVariables についてさらに検索

質問済み:

2011 年 6 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by