Function with xlsread including the excel file name as input variable

3 ビュー (過去 30 日間)
Christian F.
Christian F. 2013 年 3 月 28 日
Hi,
I have the following problem: I have multiple excel files named after countries, e.g. US,UK,FRA,JPN,... .
Now I want to write a function, which takes the name of the excel file as input string, e.g. 'JPN' and then loads the corresponding excel file e.g. data = xlsread('JPN',sheet1).
I tried using eval, but could'nt get it to work.
Best and thanks in advance, Chris

採用された回答

Walter Roberson
Walter Roberson 2013 年 3 月 28 日
filename = 'JPN';
data = xlsread(filename, sheet1);
  1 件のコメント
Christian F.
Christian F. 2013 年 3 月 28 日
Didn't expect it to be that simple.
Thanks alot!

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

その他の回答 (1 件)

Christian F.
Christian F. 2013 年 3 月 28 日
Maybe I should ad that I also want the variable, to which the data is stored, to be the named after the respective country, e.g. JPN = xlsread(JPN);

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by