How can I declare a string variable which I can call when loading a filename?

I want to plot files amongst which the only thing that changes is a word. Therefore, I want to declare a variable which I can call in the filename. Model=(CanESM); load('Model.mean.dat'); ...

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 7 月 25 日
編集済み: Azzi Abdelmalek 2016 年 7 月 25 日
model='Model.mean.dat'
load(model);

3 件のコメント

Maria Py
Maria Py 2016 年 7 月 25 日
編集済み: Maria Py 2016 年 7 月 25 日
I understand what you want to say, but I want to declare the string 'Model' as a variable and not the whole file. I want to write "Model" in the filename and read the file CanESM.mean.dat.
Adam
Adam 2016 年 7 月 25 日
Model = 'CanESM';
load( [Model '.mean.dat'] )
Model='CanESM';
file=sprintf('%s.mean.dat',Model)
load(file)

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by